Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created September 23, 2013 07:04
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/6667284 to your computer and use it in GitHub Desktop.
Save ynonp/6667284 to your computer and use it in GitHub Desktop.
var testRetryCounter = 0;
var assert = chai.assert;
$.ajax = function(opts) {
testRetryCounter++;
setTimeout(opts.error, 0);
};
var real_setTimeout = setTimeout;
setTimeout = function(code, timeout ) {
real_setTimeout(code, 0);
};
describe('Data', function() {
describe('#sendData()', function() {
it('should retry 3 times before quitting', function(done) {
var p = new PersonalData();
p.sendData();
real_setTimeout(function() {
assert.equal(testRetryCounter, 3);
done();
}, 100);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment