UNPKG

@vergiss/chooks

Version:
22 lines 625 B
import { act, renderHook } from '@testing-library/react-hooks'; import { useMount } from '../index'; describe('useMount', function () { it('should be defined', function () { expect(useMount).toBeDefined(); }); it('should invoke the callback only once', function () { var callback = jest.fn(); var hook = renderHook(function () { return useMount(callback); }); expect(callback).toBeCalledTimes(1); act(function () { hook.rerender(); }); expect(callback).toBeCalledTimes(1); act(function () { hook.unmount(); }); expect(callback).toBeCalledTimes(1); }); });