1 import { act, renderHook } from '@testing-library/react-hooks';
3 import useInstance from './useInstance';
5 describe('useInstance()', () => {
6 it('initiates with the value returned from its callback argument', () => {
7 const hook = renderHook(() => useInstance(() => 'initial'));
9 expect(hook.result.current).toBe('initial');
12 it('keeps referential equality of the initial value between render cycles', () => {
15 const hook = renderHook(() => useInstance(() => initial));
19 expect(hook.result.current).toBe(initial);
22 it('only executes the passed callback once', () => {
23 const callback = jest.fn(() => 'initial');
25 renderHook(() => useInstance(callback));
29 expect(callback).toHaveBeenCalledTimes(1);