Created
May 9, 2013 19:06
-
-
Save sarfata/5549732 to your computer and use it in GitHub Desktop.
First test pass but the second one fails - I do not understand why. The only difference is that the second test ticks 200ms (which is more than needed), while the first one only ticks 100ms.
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
var assert = require('assert'), | |
sinon = require('sinon'); | |
describe("Testing sinon useFakeTimers", function() { | |
it('sinon faking timer should work with small intervals', function() { | |
var clock = sinon.useFakeTimers(); | |
var spy = sinon.spy(); | |
setInterval(spy, 100); | |
assert(! spy.calledOnce); | |
clock.tick(101); | |
assert(spy.calledOnce); | |
clock.restore(); | |
}); | |
it('sinon faking timer should work with bigger intervals', function() { | |
var clock = sinon.useFakeTimers(); | |
var spy = sinon.spy(); | |
setInterval(spy, 100); | |
assert(! spy.calledOnce); | |
clock.tick(200); | |
assert(spy.calledOnce); | |
clock.restore(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment