UNPKG

@cnamts/vue-dot

Version:

Implementation of our Design System for the French Health Insurance

37 lines (25 loc) 600 B
import { debounce } from '../'; jest.useFakeTimers(); describe('debounce', () => { let func: jest.Mock; let debouncedFunc: () => void; beforeEach(() => { func = jest.fn(); }); it('executes just once', () => { debouncedFunc = debounce(func, 1000); for (let i = 0; i < 100; i++) { debouncedFunc(); } jest.runAllTimers(); expect(func).toBeCalledTimes(1); }); it('executes just once with default delay', () => { debouncedFunc = debounce(func); for (let i = 0; i < 100; i++) { debouncedFunc(); } jest.runAllTimers(); expect(func).toBeCalledTimes(1); }); });