mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Make _.runInContext not require a fully populated context object.
Former-commit-id: 11bf3cad2bfd3e922e7701eb7b0f48028f522ba6
This commit is contained in:
38
test/test.js
38
test/test.js
@@ -2114,6 +2114,25 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.runInContext');
|
||||
|
||||
(function() {
|
||||
test('should not require a fully populated `context` object', function() {
|
||||
var pass = false;
|
||||
|
||||
var lodash = _.runInContext({
|
||||
'setTimeout': function(callback) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
|
||||
lodash.delay(function() { pass = true; }, 32);
|
||||
ok(pass);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.shuffle');
|
||||
|
||||
(function() {
|
||||
@@ -2406,26 +2425,11 @@
|
||||
var callCount = 0,
|
||||
dateCount = 0;
|
||||
|
||||
var context = {
|
||||
'Array': Array,
|
||||
'Boolean': Boolean,
|
||||
'Function': Function,
|
||||
'Object': Object,
|
||||
'Math': Math,
|
||||
'Number': Number,
|
||||
'RegExp': RegExp,
|
||||
'String': String,
|
||||
'clearTimeout': clearTimeout,
|
||||
'isFinite': isFinite,
|
||||
'isNaN': isNaN,
|
||||
'setTimeout': setTimeout
|
||||
};
|
||||
|
||||
var lodash = _.runInContext(_.extend(context, {
|
||||
var lodash = _.runInContext({
|
||||
'Date': function() {
|
||||
return ++dateCount < 3 ? new Date : Object(Infinity);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
var throttled = lodash.throttle(function() {
|
||||
callCount++;
|
||||
|
||||
Reference in New Issue
Block a user