"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importStar(require("react"));
const jest_dom_mocks_1 = require("@shopify/jest-dom-mocks");
const test_utilities_1 = require("../test-utilities");
const breakpoint_1 = require("./breakpoint");
describe('createMediaQueries', () => {
    it('creates media queries', () => {
        const mediaQueries = breakpoint_1.createMediaQueries();
        expect(mediaQueries).toStrictEqual([
            { breakpoint: 'base', query: '(min-width: 0px) and (max-width: 749px)' },
            {
                breakpoint: 'small',
                query: '(min-width: 750px) and (max-width: 999px)',
            },
            {
                breakpoint: 'medium',
                query: '(min-width: 1000px) and (max-width: 1199px)',
            },
            { breakpoint: 'large', query: '(min-width: 1200px)' },
        ]);
    });
});
describe('useBreakpoint', () => {
    const spy = jest.fn();
    function Component() {
        const breakpoint = breakpoint_1.useBreakpoint();
        react_1.useEffect(() => {
            spy(breakpoint);
        });
        return null;
    }
    beforeEach(() => {
        jest_dom_mocks_1.matchMedia.mock();
    });
    afterEach(() => {
        jest_dom_mocks_1.matchMedia.restore();
        spy.mockReset();
    });
    it('does not match any breakpoint', () => {
        jest_dom_mocks_1.matchMedia.setMedia(() => ({
            matches: false,
        }));
        test_utilities_1.mountWithContext(<Component />);
        expect(spy.mock.calls).toMatchObject([[undefined]]);
    });
    it('matches base breakpoint', () => {
        jest_dom_mocks_1.matchMedia.setMedia((query) => ({
            matches: query === '(min-width: 0px) and (max-width: 749px)',
        }));
        test_utilities_1.mountWithContext(<Component />);
        expect(spy.mock.calls).toMatchObject([['base']]);
    });
    it('matches small breakpoint', () => {
        jest_dom_mocks_1.matchMedia.setMedia((query) => ({
            matches: query === '(min-width: 750px) and (max-width: 999px)',
        }));
        test_utilities_1.mountWithContext(<Component />);
        expect(spy.mock.calls).toMatchObject([['small']]);
    });
    it('matches medium breakpoint', () => {
        jest_dom_mocks_1.matchMedia.setMedia((query) => ({
            matches: query === '(min-width: 1000px) and (max-width: 1199px)',
        }));
        test_utilities_1.mountWithContext(<Component />);
        expect(spy.mock.calls).toMatchObject([['medium']]);
    });
    it('matches large breakpoint', () => {
        jest_dom_mocks_1.matchMedia.setMedia((query) => ({
            matches: query === '(min-width: 1200px)',
        }));
        test_utilities_1.mountWithContext(<Component />);
        expect(spy.mock.calls).toMatchObject([['large']]);
    });
});
