"use strict";
const mockInit = jest.fn();
const mockDefine = jest.fn();
jest.mock('../custom-element/registry', () => ({
    __esModule: true,
    default: () => mockDefine,
}));
describe('customElementInit', () => {
    const originalWindow = global.window;
    beforeEach(() => {
        jest.clearAllMocks();
        jest.resetModules();
        mockInit.mockReturnValue(mockDefine);
    });
    afterEach(() => {
        global.window = originalWindow;
    });
    describe('getIsImagesLazyLoadingDisabled', () => {
        it('should set disableImagesLazyLoading to true when URL has disableLazyLoading=true', () => {
            Object.defineProperty(window, 'location', {
                value: {
                    href: 'https://example.com?disableLazyLoading=true',
                },
                writable: true,
            });
            jest.isolateModules(() => {
                const { initCustomElement } = require('../customElementInit');
                initCustomElement();
            });
            expect(mockDefine).toHaveBeenCalledWith(expect.objectContaining({
                disableImagesLazyLoading: true,
            }));
        });
        it('should set disableImagesLazyLoading to false when URL does not have the param', () => {
            Object.defineProperty(window, 'location', {
                value: {
                    href: 'https://example.com',
                },
                writable: true,
            });
            jest.isolateModules(() => {
                const { initCustomElement } = require('../customElementInit');
                initCustomElement();
            });
            expect(mockDefine).toHaveBeenCalledWith(expect.objectContaining({
                disableImagesLazyLoading: false,
            }));
        });
        it('should set disableImagesLazyLoading to false when param value is not "true"', () => {
            Object.defineProperty(window, 'location', {
                value: {
                    href: 'https://example.com?disableLazyLoading=false',
                },
                writable: true,
            });
            jest.isolateModules(() => {
                const { initCustomElement } = require('../customElementInit');
                initCustomElement();
            });
            expect(mockDefine).toHaveBeenCalledWith(expect.objectContaining({
                disableImagesLazyLoading: false,
            }));
        });
        it('should allow envConsts to override the URL param value', () => {
            Object.defineProperty(window, 'location', {
                value: {
                    href: 'https://example.com?disableLazyLoading=false',
                },
                writable: true,
            });
            jest.isolateModules(() => {
                const { initCustomElement } = require('../customElementInit');
                initCustomElement({}, null, { disableImagesLazyLoading: true });
            });
            expect(mockDefine).toHaveBeenCalledWith(expect.objectContaining({
                disableImagesLazyLoading: true,
            }));
        });
        it('should include default env values', () => {
            Object.defineProperty(window, 'location', {
                value: {
                    href: 'https://example.com',
                },
                writable: true,
            });
            jest.isolateModules(() => {
                const { initCustomElement } = require('../customElementInit');
                initCustomElement();
            });
            expect(mockDefine).toHaveBeenCalledWith(expect.objectContaining({
                staticMediaUrl: 'https://static.wixstatic.com/media',
                mediaRootUrl: 'https://static.wixstatic.com',
                experiments: {},
            }));
        });
    });
});
//# sourceMappingURL=customElementInit.spec.js.map