diff --git a/lib/mock-ajax.js b/lib/mock-ajax.js index e66c422..7837980 100644 --- a/lib/mock-ajax.js +++ b/lib/mock-ajax.js @@ -65,7 +65,7 @@ getJasmineRequireObj().AjaxFakeRequest = function() { function wrapProgressEvent(xhr, eventName) { return function() { - xhr[eventName](); + xhr[eventName] && xhr[eventName](); }; } @@ -176,26 +176,13 @@ getJasmineRequireObj().AjaxFakeRequest = function() { readyState: 0, - onloadstart: function() { - }, - - onprogress: function() { - }, - - onabort: function() { - }, - - onerror: function() { - }, - - onload: function() { - }, - - ontimeout: function() { - }, - - onloadend: function() { - }, + onloadstart: null, + onprogress: null, + onabort: null, + onerror: null, + onload: null, + ontimeout: null, + onloadend: null, onreadystatechange: function(isTimeout) { }, diff --git a/src/fakeRequest.js b/src/fakeRequest.js index 8fe26c6..57b0002 100644 --- a/src/fakeRequest.js +++ b/src/fakeRequest.js @@ -20,7 +20,7 @@ getJasmineRequireObj().AjaxFakeRequest = function() { function wrapProgressEvent(xhr, eventName) { return function() { - xhr[eventName](); + xhr[eventName] && xhr[eventName](); }; } @@ -131,26 +131,13 @@ getJasmineRequireObj().AjaxFakeRequest = function() { readyState: 0, - onloadstart: function() { - }, - - onprogress: function() { - }, - - onabort: function() { - }, - - onerror: function() { - }, - - onload: function() { - }, - - ontimeout: function() { - }, - - onloadend: function() { - }, + onloadstart: null, + onprogress: null, + onabort: null, + onerror: null, + onload: null, + ontimeout: null, + onloadend: null, onreadystatechange: function(isTimeout) { },