Skip to content

Commit

Permalink
Merge pull request #2937 from zheng-kai/master
Browse files Browse the repository at this point in the history
add test unit 'throttle three times'
  • Loading branch information
jgonggrijp authored Dec 16, 2021
2 parents 7c2db70 + 90590c4 commit 92db0d9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 92db0d9

Please # to comment.