Allow stub or spy Date object safely using a closure to get a clean copy
[closes #506]
This commit is contained in:
@@ -1721,11 +1721,15 @@ if (typeof window == void 0 && typeof exports == "object") {
|
||||
}
|
||||
|
||||
getJasmineRequireObj().Timer = function() {
|
||||
var defaultNow = (function(Date) {
|
||||
return function() { return new Date().getTime(); };
|
||||
})(Date);
|
||||
|
||||
function Timer(options) {
|
||||
options = options || {};
|
||||
|
||||
var now = options.now || function() { return new Date().getTime(); },
|
||||
startTime;
|
||||
var now = options.now || defaultNow,
|
||||
startTime;
|
||||
|
||||
this.start = function() {
|
||||
startTime = now();
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
getJasmineRequireObj().Timer = function() {
|
||||
var defaultNow = (function(Date) {
|
||||
return function() { return new Date().getTime(); };
|
||||
})(Date);
|
||||
|
||||
function Timer(options) {
|
||||
options = options || {};
|
||||
|
||||
var now = options.now || function() { return new Date().getTime(); },
|
||||
startTime;
|
||||
var now = options.now || defaultNow,
|
||||
startTime;
|
||||
|
||||
this.start = function() {
|
||||
startTime = now();
|
||||
|
||||
Reference in New Issue
Block a user