Skip to content

Commit

Permalink
bug fix, verify that retry is not attempted before tiemout
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkpaul committed May 10, 2012
1 parent 1f0f20a commit 6f52462
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/jquery.ajax-retry.js
Expand Up @@ -41,7 +41,7 @@

setTimeout(function(){
timeoutDeferred.resolve();
}, this.timeout);
}, self.timeout);

return def;
}
Expand Down
11 changes: 11 additions & 0 deletions test/jquery.ajax-retry_test.js
Expand Up @@ -117,5 +117,16 @@
this.clock.tick(2001);
ok(this.requests.length === 2);
});

test('retry does not happen, if timeout has not been met', 3, function() {
var def = $.post("/test",{});
def.withTimeout(2000).retry(2);
ok(this.requests.length === 1);
this.requests[0].respond(400, { "Content-Type": "application/json" },
'{ "id": 12, "comment": "error!" }');
ok(this.requests.length === 1);
this.clock.tick(1999);
ok(this.requests.length === 1);
});

}(jQuery));

0 comments on commit 6f52462

Please sign in to comment.