Permalink
Browse files

Added test simulating server timeouts with jquery deferred callbacks.

  • Loading branch information...
1 parent d39f5cd commit 358b350167960850b5becb3fa4af6b234e17555e @michaelbrooks michaelbrooks committed Apr 7, 2012
Showing with 26 additions and 0 deletions.
  1. +26 −0 test/test.js
View
@@ -843,6 +843,32 @@ asyncTest('Forcing timeout', function() {
$.mockjaxClear();
});
+// FORCE SIMULATION OF SERVER TIMEOUTS WITH PROMISES
+asyncTest('Forcing timeout with Promises', function() {
+ $.mockjax({
+ url: '/response-callback',
+ responseText: 'done',
+ isTimeout: true
+ });
+
+ var request = $.ajax({
+ url: '/response-callback'
+ });
+
+ request.done(function(xhr) {
+ ok(true, "error callback was called");
+ });
+
+ request.fail(function(response) {
+ ok(false, "should not be be successful");
+ });
+
+ request.always(function(xhr) {
+ start();
+ });
+
+ $.mockjaxClear();
+});
// DYNAMICALLY GENERATING MOCK DEFINITIONS
asyncTest('Dynamic mock definition', function() {
$.mockjax( function( settings ) {

0 comments on commit 358b350

Please sign in to comment.