1 import { renderHook } from '@testing-library/react-hooks';
3 import useEffectOnce from './useEffectOnce';
5 describe('useEffect()', () => {
6 it('initiates with the value returned from its callback argument', () => {
8 const { rerender } = renderHook(() => useEffectOnce(fn));
10 expect(fn).toHaveBeenCalledTimes(1);
13 it('only calls once between renders', () => {
15 const { rerender } = renderHook<{ a: string }, void>(({ a = '' }) => useEffectOnce(fn, [a]));
17 expect(fn).toHaveBeenCalledTimes(1);
19 expect(fn).toHaveBeenCalledTimes(1);