Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created September 23, 2013 07:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ynonp/6667378 to your computer and use it in GitHub Desktop.
Save ynonp/6667378 to your computer and use it in GitHub Desktop.
var testRetryCounter = 0;
var assert = chai.assert;
$.ajax = function(opts) {
testRetryCounter++;
setTimeout(opts.error, 0);
};
describe('Data', function() {
describe('#sendData()', function() {
var clock;
before(function () { clock = sinon.useFakeTimers(); });
after(function () { clock.restore(); });
it('should retry 3 times before quitting', function() {
var p = new PersonalData();
p.sendData();
assert.equal(testRetryCounter, 1);
clock.tick(3000);
assert.equal(testRetryCounter, 2);
clock.tick(3000);
assert.equal(testRetryCounter, 3);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment