16 lines
262 B
TypeScript
16 lines
262 B
TypeScript
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);
|
|
});
|