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() {
|
getJasmineRequireObj().Timer = function() {
|
||||||
|
var defaultNow = (function(Date) {
|
||||||
|
return function() { return new Date().getTime(); };
|
||||||
|
})(Date);
|
||||||
|
|
||||||
function Timer(options) {
|
function Timer(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
var now = options.now || function() { return new Date().getTime(); },
|
var now = options.now || defaultNow,
|
||||||
startTime;
|
startTime;
|
||||||
|
|
||||||
this.start = function() {
|
this.start = function() {
|
||||||
startTime = now();
|
startTime = now();
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
getJasmineRequireObj().Timer = function() {
|
getJasmineRequireObj().Timer = function() {
|
||||||
|
var defaultNow = (function(Date) {
|
||||||
|
return function() { return new Date().getTime(); };
|
||||||
|
})(Date);
|
||||||
|
|
||||||
function Timer(options) {
|
function Timer(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
var now = options.now || function() { return new Date().getTime(); },
|
var now = options.now || defaultNow,
|
||||||
startTime;
|
startTime;
|
||||||
|
|
||||||
this.start = function() {
|
this.start = function() {
|
||||||
startTime = now();
|
startTime = now();
|
||||||
|
|||||||
Reference in New Issue
Block a user