import * as React from 'react'; import {createRoot} from 'react-dom/client'; import { act } from '@testing-library/react'; import { useWindowSize } from '../src'; describe('useWindowSize', () => { let container: Element; beforeEach(() => { container = document.createElement('div'); document.body.appendChild(container); }); afterEach(() => { document.body.removeChild(container); }); it('should return the window size', () => { const Component = () => { const { width, height } = useWindowSize(); return ( <>
{height}
{width}
> ); }; act(() => { const root = createRoot(container) root.render(