UNPKG

@vergiss/chooks

Version:
31 lines (27 loc) 813 B
"use strict"; import "core-js/modules/es.object.define-property"; Object.defineProperty(exports, "__esModule", { value: true }); var react_hooks_1 = require("@testing-library/react-hooks"); var index_1 = require("../index"); describe('useMount', function () { it('should be defined', function () { expect(index_1.useMount).toBeDefined(); }); it('should invoke the callback only once', function () { var callback = jest.fn(); var hook = react_hooks_1.renderHook(function () { return index_1.useMount(callback); }); expect(callback).toBeCalledTimes(1); react_hooks_1.act(function () { hook.rerender(); }); expect(callback).toBeCalledTimes(1); react_hooks_1.act(function () { hook.unmount(); }); expect(callback).toBeCalledTimes(1); }); });