mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Add isModularize check for _.throttle test for system time of 0.
This commit is contained in:
42
test/test.js
42
test/test.js
@@ -22635,31 +22635,37 @@
|
||||
|
||||
var done = assert.async();
|
||||
|
||||
var callCount = 0,
|
||||
dateCount = 0;
|
||||
if (!isModularize) {
|
||||
var callCount = 0,
|
||||
dateCount = 0;
|
||||
|
||||
var lodash = _.runInContext({
|
||||
'Date': {
|
||||
'now': function() {
|
||||
return ++dateCount == 1 ? 0 : +new Date;
|
||||
var lodash = _.runInContext({
|
||||
'Date': {
|
||||
'now': function() {
|
||||
return ++dateCount == 1 ? 0 : +new Date;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var throttled = _.throttle(function(value) {
|
||||
callCount++;
|
||||
return value;
|
||||
}, 32);
|
||||
var throttled = _.throttle(function(value) {
|
||||
callCount++;
|
||||
return value;
|
||||
}, 32);
|
||||
|
||||
var actual = [throttled('a'), throttled('b'), throttled('c')];
|
||||
var actual = [throttled('a'), throttled('b'), throttled('c')];
|
||||
|
||||
assert.strictEqual(callCount, 1);
|
||||
assert.deepEqual(actual, ['a', 'a', 'a']);
|
||||
assert.strictEqual(callCount, 1);
|
||||
assert.deepEqual(actual, ['a', 'a', 'a']);
|
||||
|
||||
setTimeout(function() {
|
||||
assert.strictEqual(callCount, 2);
|
||||
setTimeout(function() {
|
||||
assert.strictEqual(callCount, 2);
|
||||
done();
|
||||
}, 64);
|
||||
}
|
||||
else {
|
||||
skipAssert(assert, 3);
|
||||
done();
|
||||
}, 64);
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user