const importModule = () => import('@utilities/codeFullscreenModeSwitcher'); describe('CodeFullScreenModeSwitcher Utility', () => { let addFullScreenModeControl, getFullScreenModeStatus; let onPressEscape, onPopstate; const getFullScreenElements = () => ['.js-fullscreen-code.is-open', '.js-code-highlight.is-fullscreen'].map( (selector) => document.body.querySelector(selector), ); const testFullScreenElements = ({ exists }) => { for (const element of getFullScreenElements()) { if (exists) expect(element).not.toBeNull(); else expect(element).toBeNull(); } }; const testNonFullScreen = () => { expect(getFullScreenModeStatus()).toBe(false); testFullScreenElements({ exists: false }); expect(document.body.style.overflow).toBe(''); }; const testFullScreen = () => { expect(getFullScreenModeStatus()).toBe(true); testFullScreenElements({ exists: true }); expect(document.body.style.overflow).toBe('hidden'); }; const getEnterFullScreenButtons = () => document.getElementsByClassName('js-fullscreen-code-action'); beforeAll(() => { global.scrollTo = jest.fn(); document.body.innerHTML = `