Я пытаюсь издеваться над своей служебной функцией debounce, но не хватает моего освещения. Все проходит, но ни одна из моих линий не покрыта. Я не использую _loda sh.
Test. js
import { debounce } from '../../data/utils/utils';
afterEach(cleanup);
jest.useFakeTimers();
describe('debounce util', () => {
const callback = jest.fn();
beforeEach(() => {
debounce(callback, 500);
});
it('should call debounce util', () => {
for (let i = 0; i < 100; i++) {
debounce(callback, 10);
}
jest.runAllTimers();
expect(callback).toBeCalledTimes(0);
});
});
Util. js
export const debounce = function debounce(fn, ms) {
let timer;
return () => {
clearTimeout(timer);
timer = setTimeout(() => {
timer = null;
fn.apply(this, arguments);
}, ms);
};
};