mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Add _.throttle unit test to test lastCalled.
Former-commit-id: 528ebd3514aacafcde55fad989f955f1fe403811
This commit is contained in:
18
test/test.js
18
test/test.js
@@ -2843,11 +2843,27 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
strictEqual(withCount, 2);
|
equal(withCount, 2);
|
||||||
strictEqual(withoutCount, 1);
|
strictEqual(withoutCount, 1);
|
||||||
QUnit.start();
|
QUnit.start();
|
||||||
}, 64);
|
}, 64);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
asyncTest('should not update `lastCalled`, at the end of the timeout, when `trailing` is `false`', function() {
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
|
var throttled = _.throttle(function() {
|
||||||
|
count++;
|
||||||
|
}, 64, { 'trailing': false });
|
||||||
|
|
||||||
|
_.times(2, throttled);
|
||||||
|
setTimeout(function() { _.times(2, throttled); }, 100);
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
equal(count, 2);
|
||||||
|
QUnit.start();
|
||||||
|
}, 128);
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user