mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 17:37:50 +00:00
Add _.throttle unit test for recursive calls.
Former-commit-id: 7208516b56905c83df73aef6b02cee0101602349
This commit is contained in:
22
test/test.js
22
test/test.js
@@ -642,6 +642,23 @@
|
||||
}
|
||||
ok(counter > 1);
|
||||
});
|
||||
|
||||
asyncTest('supports recursive calls', function() {
|
||||
var counter = 0;
|
||||
var throttled = _.throttle(function() {
|
||||
counter++;
|
||||
if (counter < 4) {
|
||||
throttled();
|
||||
}
|
||||
}, 100);
|
||||
|
||||
setTimeout(function() {
|
||||
ok(counter > 1);
|
||||
QUnit.start();
|
||||
}, 220);
|
||||
|
||||
throttled();
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -790,6 +807,7 @@
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// explicitly call `QUnit.start()` for Narwhal, Rhino, and RingoJS
|
||||
QUnit.start();
|
||||
|
||||
if (!window.document) {
|
||||
QUnit.start();
|
||||
}
|
||||
}(typeof global == 'object' && global || this));
|
||||
|
||||
Reference in New Issue
Block a user