import useReducedMotion from './useReducedMotion';
import { act, renderHook } from '@testing-library/react-hooks';
import MatchMedia from './__mocks__/mq';
var MOTION_MQ = {
  reduced: '(prefers-reduced-motion: reduce)',
  default: '(prefers-reduced-motion: default)'
};
var matchMedia;
describe('useReducedMotion', function () {
  afterEach(function () {
    matchMedia.destroy();
  });
  it('returns true if user preference is to reduce motion', function () {
    matchMedia = new MatchMedia(MOTION_MQ.reduced);

    var _renderHook = renderHook(function () {
      return useReducedMotion();
    }),
        result = _renderHook.result;

    expect(result.current).toBe(true);
  });
  it('returns true if user preference is not to reduce motion', function () {
    matchMedia = new MatchMedia(MOTION_MQ.default);

    var _renderHook2 = renderHook(function () {
      return useReducedMotion();
    }),
        result = _renderHook2.result;

    expect(result.current).toBe(false);
  });
  it('change result accordingly when user changes motion settings', function () {
    matchMedia = new MatchMedia(MOTION_MQ.default);

    var _renderHook3 = renderHook(function () {
      return useReducedMotion();
    }),
        result = _renderHook3.result;

    expect(result.current).toBe(false);
    act(function () {
      return matchMedia.updateMediaQuery(MOTION_MQ.reduced);
    });
    expect(result.current).toBe(true);
    act(function () {
      return matchMedia.updateMediaQuery(MOTION_MQ.default);
    });
    expect(result.current).toBe(false);
    act(function () {
      return matchMedia.updateMediaQuery(MOTION_MQ.reduced);
    });
    expect(result.current).toBe(true);
  });
});