Allow stub or spy Date object safely using a closure to get a clean copy

[closes #506]
This commit is contained in:
tcorral
2014-01-24 02:02:23 +01:00
committed by Sheel Choksi
parent 21b01f4a5d
commit b5775aec4f
2 changed files with 12 additions and 4 deletions

View File

@@ -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();

View File

@@ -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();