mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Add mock Date.now and setTimeout tests.
This commit is contained in:
32
test/test.js
32
test/test.js
@@ -4733,6 +4733,22 @@
|
|||||||
done();
|
done();
|
||||||
}, 64);
|
}, 64);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('should work with mocked `setTimeout`', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
var pass = false,
|
||||||
|
setTimeout = root.setTimeout;
|
||||||
|
|
||||||
|
root.setTimeout = function(func) { func(); };
|
||||||
|
|
||||||
|
_.delay(function() {
|
||||||
|
pass = true;
|
||||||
|
}, 32);
|
||||||
|
|
||||||
|
assert.ok(pass);
|
||||||
|
root.setTimeout = setTimeout;
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
@@ -16244,6 +16260,18 @@
|
|||||||
done();
|
done();
|
||||||
}, 32);
|
}, 32);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('should work with mocked `Date.now`', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
var now = Date.now;
|
||||||
|
Date.now = stubA;
|
||||||
|
|
||||||
|
var actual = _.now();
|
||||||
|
Date.now = now;
|
||||||
|
|
||||||
|
assert.strictEqual(actual, 'a');
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
@@ -19648,9 +19676,7 @@
|
|||||||
|
|
||||||
if (!isModularize) {
|
if (!isModularize) {
|
||||||
var lodash = _.runInContext({
|
var lodash = _.runInContext({
|
||||||
'setTimeout': function(callback) {
|
'setTimeout': function(func) { func(); }
|
||||||
callback();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var pass = false;
|
var pass = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user