Add _.throttle unit test to test lastCalled.

Former-commit-id: 528ebd3514aacafcde55fad989f955f1fe403811
This commit is contained in:
John-David Dalton
2013-04-17 21:36:37 -07:00
parent e80e1dab4d
commit 2a92600fa7

View File

@@ -2843,11 +2843,27 @@
});
setTimeout(function() {
strictEqual(withCount, 2);
equal(withCount, 2);
strictEqual(withoutCount, 1);
QUnit.start();
}, 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);
});
}());
/*--------------------------------------------------------------------------*/