Skip to content

Commit

Permalink
Fixed ignored global restore test
Browse files Browse the repository at this point in the history
  • Loading branch information
pimterry committed Dec 24, 2013
1 parent 3c2042e commit ac17669
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions test/sinon/util/fake_timers_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,27 +862,30 @@ buster.testCase("sinon.clock", {
assert.same(clearInterval, sinon.timers.clearInterval);
},

"//deletes global property if it originally did not have own property":
"Not quite sure why this test was initially commented out - TODO: Fix"
/*function () {
// remove this properties from the global object ("hasOwnProperty" false)
// delete this.global.clearTimeout;
// delete this.global.setInterval;
// // set these properties to the global object ("hasOwnProperty" true)
// this.global.clearInterval = this.global.clearInterval;
// this.global.setTimeout = this.global.clearInterval;
// this.clock = sinon.useFakeTimers();
// this.clock.restore();
// // these properties should be removed from the global object directly.
// assert.isFalse(this.global.hasOwnProperty("clearTimeout"));
// assert.isFalse(this.global.hasOwnProperty("setInterval"));
// // these properties should be added back into the global object directly.
// assert(this.global.hasOwnProperty("clearInterval"));
// assert(this.global.hasOwnProperty("setTimeout"));
}*/,
"deletes global property on restore if it was inherited onto the global object": function () {
// Give the global object an inherited 'tick' method
delete this.global.tick;
this.global.__proto__.tick = function() { };

this.clock = sinon.useFakeTimers('tick');
assert.isTrue(this.global.hasOwnProperty("tick"));
this.clock.restore();

assert.isFalse(this.global.hasOwnProperty("tick"));
delete this.global.__proto__.tick;
},

"restores global property on restore if it is present on the global object itself": function () {
// Directly give the global object a tick method
this.global.tick = function () { };

this.clock = sinon.useFakeTimers('tick');
assert.isTrue(this.global.hasOwnProperty("tick"));
this.clock.restore();

assert.isTrue(this.global.hasOwnProperty("tick"));
delete this.global.tick;
},

"fakes Date constructor": function () {
this.clock = sinon.useFakeTimers(0);
Expand Down

0 comments on commit ac17669

Please sign in to comment.