Last active
August 29, 2015 13:57
-
-
Save opichals/9544091 to your computer and use it in GitHub Desktop.
Mod to make sinon.useFakeTimers() compatible with Ember.js runloop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!sinon._originalUseFakeTimers) { | |
sinon._originalUseFakeTimers = sinon.useFakeTimers; | |
sinon.useFakeTimers = function() { | |
// make sure we don't override window.Date used in | |
// Backburner.setTimeout() to optimize window.setTimeout() call numbers | |
return sinon._originalUseFakeTimers.apply(this, [new Date().getTime(), "setTimeout", "setInterval", "clearTimeout", "clearInterval"]); | |
}; | |
sinon._originalTest = sinon.test; | |
sinon.test = function(callback) { | |
return sinon._originalTest.call(this, function() { | |
callback.apply(this, arguments); | |
// wait for further runloops to finish (2s is the mocha timeout) | |
this.clock.tick(2000); | |
}); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment