1 import { renderHook } from '@testing-library/react-hooks';
3 import usePrevious from './usePrevious';
5 describe('usePrevious()', () => {
6 it('remembers the value passed to it in the previous render cycle', () => {
7 const hook = renderHook(({ initial }) => usePrevious(initial), { initialProps: { initial: 0 } });
9 hook.rerender({ initial: 1 });
11 const previous = hook.result.current;
13 expect(previous).toBe(0);