Skip to content

Commit

Permalink
add test unit 'throttle three times'
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengkai committed Aug 9, 2021
1 parent f098f61 commit 90590c4
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 90590c4

Please sign in to comment.