add test case for debounce
This commit is contained in:
parent
6a8b314ca0
commit
ee80b55a1b
1 changed files with 10 additions and 1 deletions
|
@ -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");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue