add test case for debounce

This commit is contained in:
Artur Haurylkevich 2019-10-17 22:01:44 +03:00 committed by GitHub
parent 6a8b314ca0
commit ee80b55a1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,15 @@ describe("debounce", function() {
this.clock.restore(); this.clock.restore();
}); });
it("trigger the fuction execution immediately", function () {
let mode;
const f = () => mode='leading';
debounce(f, 1000)(); // runs without a delay
assert.equal(mode, 'leading');
});
it("calls the function at maximum once in ms milliseconds", function() { it("calls the function at maximum once in ms milliseconds", function() {
let log = ''; let log = '';
@ -38,4 +47,4 @@ describe("debounce", function() {
obj.f("test"); obj.f("test");
}); });
}); });