From 90590c495ab55752b63b44d62720b86dc1bc172e Mon Sep 17 00:00:00 2001 From: zhengkai Date: Mon, 9 Aug 2021 10:58:19 +0800 Subject: [PATCH] add test unit 'throttle three times' --- test/functions.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/functions.js b/test/functions.js index 20144179a..2bbcdbb46 100644 --- a/test/functions.js +++ b/test/functions.js @@ -244,6 +244,16 @@ _.delay(function(){ assert.strictEqual(counter, 2, 'incr was called twice'); done(); }, 64); }); + QUnit.test('throttle three times', function(assert) { + assert.expect(1); + var done = assert.async(); + var counter = 0; + var incr = function(){ counter++; }; + var throttledIncr = _.throttle(incr, 32); + throttledIncr(); throttledIncr(); throttledIncr(); + _.delay(function(){ assert.strictEqual(counter, 2, 'incr was called twice'); done(); }, 64); + }); + QUnit.test('more throttling', function(assert) { assert.expect(3); var done = assert.async();