jasmine-ajax
Advanced tools
Comparing version 3.3.1 to 3.4.0
{ | ||
"name": "jasmine-ajax", | ||
"description": "A library for faking Ajax responses in your Jasmine suite.", | ||
"version": "3.3.1", | ||
"version": "3.4.0", | ||
"main": "lib/mock-ajax.js", | ||
@@ -14,3 +14,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"jasmine" : "~2" | ||
"jasmine" : "~3" | ||
}, | ||
@@ -17,0 +17,0 @@ "moduleType": [ |
@@ -300,3 +300,3 @@ /* | ||
this.method = arguments[0]; | ||
this.url = arguments[1]; | ||
this.url = arguments[1] + ''; | ||
this.username = arguments[3]; | ||
@@ -313,3 +313,3 @@ this.password = arguments[4]; | ||
} | ||
if(this.requestHeaders.hasOwnProperty(header)) { | ||
@@ -371,3 +371,3 @@ this.requestHeaders[header] = [this.requestHeaders[header], value].join(', '); | ||
} else if (stub.isError()) { | ||
this.responseError(); | ||
this.responseError(stub); | ||
} else if (stub.isTimeout()) { | ||
@@ -464,2 +464,5 @@ this.responseTimeout(); | ||
} | ||
if (response.responseJSON) { | ||
this.responseText = JSON.stringify(response.responseJSON); | ||
} | ||
@@ -490,6 +493,11 @@ if ('response' in response) { | ||
responseError: function() { | ||
responseError: function(response) { | ||
if (!response) { | ||
response = {}; | ||
} | ||
if (this.readyState === FakeXMLHttpRequest.DONE) { | ||
throw new Error("FakeXMLHttpRequest already completed"); | ||
} | ||
this.status = response.status; | ||
this.statusText = response.statusText || ""; | ||
this.readyState = FakeXMLHttpRequest.DONE; | ||
@@ -524,4 +532,4 @@ this.eventBus.trigger('readystatechange'); | ||
this.install = function() { | ||
if (global.XMLHttpRequest === mockAjaxFunction) { | ||
throw "MockAjax is already installed."; | ||
if (global.XMLHttpRequest !== realAjaxFunction) { | ||
throw new Error("Jasmine Ajax was unable to install over a custom XMLHttpRequest. Is Jasmine Ajax already installed?"); | ||
} | ||
@@ -534,3 +542,3 @@ | ||
if (global.XMLHttpRequest !== mockAjaxFunction) { | ||
throw "MockAjax not installed."; | ||
throw new Error("MockAjax not installed."); | ||
} | ||
@@ -652,3 +660,4 @@ global.XMLHttpRequest = realAjaxFunction; | ||
this.action = RETURN; | ||
this.status = options.status || 200; | ||
this.status = (typeof options.status !== 'undefined') ? options.status : 200; | ||
this.statusText = options.statusText; | ||
@@ -666,4 +675,8 @@ this.contentType = options.contentType; | ||
this.andError = function() { | ||
this.andError = function(options) { | ||
if (!options) { | ||
options = {}; | ||
} | ||
this.action = ERROR; | ||
this.status = options.status || 500; | ||
}; | ||
@@ -670,0 +683,0 @@ |
{ | ||
"name": "jasmine-ajax", | ||
"description": "A library for faking Ajax responses in your Jasmine suite", | ||
"version": "3.3.1", | ||
"version": "3.4.0", | ||
"main": "lib/mock-ajax.js", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48195
14
702
305