From ee80b55a1b06d0c270b0b9e093b744e57f108c45 Mon Sep 17 00:00:00 2001 From: Artur Haurylkevich Date: Thu, 17 Oct 2019 22:01:44 +0300 Subject: [PATCH] add test case for debounce --- .../03-debounce/_js.view/test.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/1-js/06-advanced-functions/09-call-apply-decorators/03-debounce/_js.view/test.js b/1-js/06-advanced-functions/09-call-apply-decorators/03-debounce/_js.view/test.js index 16dc171e..8136b873 100644 --- a/1-js/06-advanced-functions/09-call-apply-decorators/03-debounce/_js.view/test.js +++ b/1-js/06-advanced-functions/09-call-apply-decorators/03-debounce/_js.view/test.js @@ -7,6 +7,15 @@ describe("debounce", function() { 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() { let log = ''; @@ -38,4 +47,4 @@ describe("debounce", function() { obj.f("test"); }); -}); \ No newline at end of file +});