import React from 'react'; import { render } from '../../../tests/utils'; import useSize from '../hooks/useSize'; describe('useSize', () => { it('useSize', () => { const Demo: React.FC<{ size?: any }> = ({ size }) =>
{useSize(size)}
; const { container, rerender } = render(); expect(container.querySelector('div')?.textContent).toBe(''); rerender(); expect(container.querySelector('div')?.textContent).toBe('test-size1'); rerender( 'test-size2'} />); expect(container.querySelector('div')?.textContent).toBe('test-size2'); rerender(); expect(container.querySelector('div')?.textContent).toBe(''); }); });