Skip to content

Instantly share code, notes, and snippets.

@r01010010
Last active August 29, 2015 14:09
Show Gist options
  • Save r01010010/97284164f162652e8d60 to your computer and use it in GitHub Desktop.
Save r01010010/97284164f162652e8d60 to your computer and use it in GitHub Desktop.
var sinon = require('sinon');
var chai = require('chai');
expect = chai.expect;
should = chai.should();
assert = chai.assert;
var clock;
beforeEach(function () {
clock = sinon.useFakeTimers();
});
afterEach(function () {
clock.restore();
});
it("should time out after 5000 ms", function() {
var timedOut = false;
setTimeout(function () {
console.log('executed!');
timedOut = true;
}, 5000);
timedOut.should.be.false;
clock.tick(5500);
timedOut.should.be.true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment