mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07: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 done = assert.async();
|
||||||
|
|
||||||
var callCount = 0,
|
if (!isModularize) {
|
||||||
dateCount = 0;
|
var callCount = 0,
|
||||||
|
dateCount = 0;
|
||||||
|
|
||||||
var lodash = _.runInContext({
|
var lodash = _.runInContext({
|
||||||
'Date': {
|
'Date': {
|
||||||
'now': function() {
|
'now': function() {
|
||||||
return ++dateCount == 1 ? 0 : +new Date;
|
return ++dateCount == 1 ? 0 : +new Date;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
var throttled = _.throttle(function(value) {
|
var throttled = _.throttle(function(value) {
|
||||||
callCount++;
|
callCount++;
|
||||||
return value;
|
return value;
|
||||||
}, 32);
|
}, 32);
|
||||||
|
|
||||||
var actual = [throttled('a'), throttled('b'), throttled('c')];
|
var actual = [throttled('a'), throttled('b'), throttled('c')];
|
||||||
|
|
||||||
assert.strictEqual(callCount, 1);
|
assert.strictEqual(callCount, 1);
|
||||||
assert.deepEqual(actual, ['a', 'a', 'a']);
|
assert.deepEqual(actual, ['a', 'a', 'a']);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
assert.strictEqual(callCount, 2);
|
assert.strictEqual(callCount, 2);
|
||||||
|
done();
|
||||||
|
}, 64);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipAssert(assert, 3);
|
||||||
done();
|
done();
|
||||||
}, 64);
|
}
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user