import React from 'react'; import { useScrollLock } from '../hooks'; import renderWithTheme from '../../../testUtils/renderWithTheme'; window.scrollTo = jest.fn(); describe('scroll lock', () => { const SomeComponent = ({ open = false }: { open?: boolean }) => { useScrollLock(open); return
Test
; }; it('set body position correctly based on component open prop', () => { expect(document.body.style.position).toEqual(''); const { rerender } = renderWithTheme(); expect(document.body.style.position).toEqual('fixed'); rerender(); expect(document.body.style.position).toEqual(''); }); it('set body position correctly based on component mounted state', () => { expect(document.body.style.position).toEqual(''); const { unmount } = renderWithTheme(); expect(document.body.style.position).toEqual('fixed'); unmount(); expect(document.body.style.position).toEqual(''); }); });