Skip to content

Commit

Permalink
Fix [#48420035]
Browse files Browse the repository at this point in the history
  • Loading branch information
Davis W. Frank committed Apr 20, 2013
1 parent 9c4467b commit dd8d3f9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/jasmine-core/jasmine.js
Expand Up @@ -896,7 +896,7 @@ jasmine.Clock = function(global, delayedFunctionScheduler) {
}
return timer.setTimeout(fn, delay);
}
return timer.setTimeout.apply(null, arguments);
return timer.setTimeout.apply(global, arguments);
};

self.setInterval = function(fn, delay, params) {
Expand All @@ -906,15 +906,15 @@ jasmine.Clock = function(global, delayedFunctionScheduler) {
}
return timer.setInterval(fn, delay);
}
return timer.setInterval.apply(null, arguments);
return timer.setInterval.apply(global, arguments);
};

self.clearTimeout = function(id) {
return timer.clearTimeout(id);
return timer.clearTimeout.call(global, id);
};

self.clearInterval = function(id) {
return timer.clearInterval(id);
return timer.clearInterval.call(global, id);
};

self.tick = function(millis) {
Expand Down
20 changes: 20 additions & 0 deletions spec/core/ClockSpec.js
Expand Up @@ -291,4 +291,24 @@ describe("Clock (acceptance)", function() {
clock.tick(5);
expect(delayedFn1).toHaveBeenCalled();
});

it("calls the global clearTimeout correctly when not installed", function () {
var delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearTimeout']),
global = originalJasmine.getGlobal(),
clock = new jasmine.Clock(global, delayedFunctionScheduler);

expect(function() {
clock.clearTimeout(123)
}).not.toThrow();
});

it("calls the global clearTimeout correctly when not installed", function () {
var delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearTimeout']),
global = originalJasmine.getGlobal(),
clock = new jasmine.Clock(global, delayedFunctionScheduler);

expect(function() {
clock.clearInterval(123)
}).not.toThrow();
});
});
8 changes: 4 additions & 4 deletions src/core/Clock.js
Expand Up @@ -33,7 +33,7 @@ jasmine.Clock = function(global, delayedFunctionScheduler) {
}
return timer.setTimeout(fn, delay);
}
return timer.setTimeout.apply(null, arguments);
return timer.setTimeout.apply(global, arguments);
};

self.setInterval = function(fn, delay, params) {
Expand All @@ -43,15 +43,15 @@ jasmine.Clock = function(global, delayedFunctionScheduler) {
}
return timer.setInterval(fn, delay);
}
return timer.setInterval.apply(null, arguments);
return timer.setInterval.apply(global, arguments);
};

self.clearTimeout = function(id) {
return timer.clearTimeout(id);
return timer.clearTimeout.call(global, id);
};

self.clearInterval = function(id) {
return timer.clearInterval(id);
return timer.clearInterval.call(global, id);
};

self.tick = function(millis) {
Expand Down

0 comments on commit dd8d3f9

Please sign in to comment.