/* eslint-env jest */ import { act } from 'react'; import { createRoot, type Root } from 'react-dom/client'; import ProblemsList from '../ProblemsList'; ( globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean } ).IS_REACT_ACT_ENVIRONMENT = true; let root: Root; let host: HTMLDivElement; beforeEach(() => { host = document.createElement('div'); document.body.appendChild(host); root = createRoot(host); }); afterEach(() => { act(() => root.unmount()); host.remove(); }); it('does not praise a list that was never read', async () => { await act(async () => { root.render(); }); expect(host.textContent).toContain('not available right now'); expect(host.textContent).not.toContain('great job'); await act(async () => { root.render(); }); expect(host.textContent).toContain('No problems detected this week'); });