@@ -862,27 +862,30 @@ buster.testCase("sinon.clock", {
862862 assert . same ( clearInterval , sinon . timers . clearInterval ) ;
863863 } ,
864864
865- "//deletes global property if it originally did not have own property" :
866- "Not quite sure why this test was initially commented out - TODO: Fix"
867- /*function () {
868- // remove this properties from the global object ("hasOwnProperty" false)
869- // delete this.global.clearTimeout;
870- // delete this.global.setInterval;
871- // // set these properties to the global object ("hasOwnProperty" true)
872- // this.global.clearInterval = this.global.clearInterval;
873- // this.global.setTimeout = this.global.clearInterval;
874-
875- // this.clock = sinon.useFakeTimers();
876- // this.clock.restore();
877-
878- // // these properties should be removed from the global object directly.
879- // assert.isFalse(this.global.hasOwnProperty("clearTimeout"));
880- // assert.isFalse(this.global.hasOwnProperty("setInterval"));
881-
882- // // these properties should be added back into the global object directly.
883- // assert(this.global.hasOwnProperty("clearInterval"));
884- // assert(this.global.hasOwnProperty("setTimeout"));
885- }*/ ,
865+ "deletes global property on restore if it was inherited onto the global object" : function ( ) {
866+ // Give the global object an inherited 'tick' method
867+ delete this . global . tick ;
868+ this . global . __proto__ . tick = function ( ) { } ;
869+
870+ this . clock = sinon . useFakeTimers ( 'tick' ) ;
871+ assert . isTrue ( this . global . hasOwnProperty ( "tick" ) ) ;
872+ this . clock . restore ( ) ;
873+
874+ assert . isFalse ( this . global . hasOwnProperty ( "tick" ) ) ;
875+ delete this . global . __proto__ . tick ;
876+ } ,
877+
878+ "restores global property on restore if it is present on the global object itself" : function ( ) {
879+ // Directly give the global object a tick method
880+ this . global . tick = function ( ) { } ;
881+
882+ this . clock = sinon . useFakeTimers ( 'tick' ) ;
883+ assert . isTrue ( this . global . hasOwnProperty ( "tick" ) ) ;
884+ this . clock . restore ( ) ;
885+
886+ assert . isTrue ( this . global . hasOwnProperty ( "tick" ) ) ;
887+ delete this . global . tick ;
888+ } ,
886889
887890 "fakes Date constructor" : function ( ) {
888891 this . clock = sinon . useFakeTimers ( 0 ) ;
0 commit comments