/* eslint-env jest */ import { act } from 'react'; import { createRoot, type Root } from 'react-dom/client'; import { useAppStateContext } from '../../context/user.data.context'; import { isContentSiteType, useContentSite } from '../content-site'; jest.mock('../../context/user.data.context', () => ({ useAppStateContext: jest.fn(), })); ( globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean } ).IS_REACT_ACT_ENVIRONMENT = true; const mockedContext = useAppStateContext as jest.Mock; /** * Prints what the hook answers, so the rendered text can be read. * * @return {JSX.Element} The answer. */ const SiteTypeProbe = (): JSX.Element => { const reading = useContentSite() ? 'content site' : 'store'; return
{reading}
; }; let root: Root; let host: HTMLDivElement; beforeEach(() => { host = document.createElement('div'); document.body.appendChild(host); root = createRoot(host); }); afterEach(() => { act(() => root.unmount()); host.remove(); }); const readingFor = (user: unknown): string => { mockedContext.mockReturnValue({ user }); act(() => root.render(