utils/ts-src/once.test.ts

16 lines
262 B
TypeScript
Raw Permalink Normal View History

2020-11-17 11:16:34 +00:00
import { once } from './once';
test('It should trigger once', function () {
const func = jest.fn();
const onetimeFunc = once(func);
onetimeFunc();
expect(func).toHaveBeenCalledTimes(1);
onetimeFunc();
expect(func).toHaveBeenCalledTimes(1);
});