Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jasmine-ajax

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasmine-ajax - npm Package Compare versions

Comparing version 3.4.0 to 4.0.0

release_notes/4.0.0.md

2

bower.json
{
"name": "jasmine-ajax",
"description": "A library for faking Ajax responses in your Jasmine suite.",
"version": "3.4.0",
"version": "4.0.0",
"main": "lib/mock-ajax.js",

@@ -6,0 +6,0 @@ "license": "MIT",

/*
Jasmine-Ajax - v3.3.1: a set of helpers for testing AJAX requests under the Jasmine
Jasmine-Ajax - v3.4.0: a set of helpers for testing AJAX requests under the Jasmine
BDD framework for JavaScript.

@@ -360,17 +360,4 @@

var stub = stubTracker.findStub(this.url, data, this.method);
this.dispatchStub(stub);
},
dispatchStub: function(stub) {
if (stub) {
if (stub.isReturn()) {
this.respondWith(stub);
} else if (stub.isError()) {
this.responseError(stub);
} else if (stub.isTimeout()) {
this.responseTimeout();
} else if (stub.isCallFunction()) {
this.responseCallFunction(stub);
}
stub.handleRequest(this);
}

@@ -506,6 +493,66 @@ },

responseCallFunction: function(stub) {
stub.action = undefined;
stub.functionToCall(stub, this);
this.dispatchStub(stub);
startStream: function(options) {
if (!options) {
options = {};
}
if (this.readyState >= FakeXMLHttpRequest.LOADING) {
throw new Error("FakeXMLHttpRequest already loading or finished");
}
this.status = 200;
this.responseText = "";
this.statusText = "";
this.responseHeaders = normalizeHeaders(options.responseHeaders, options.contentType);
this.readyState = FakeXMLHttpRequest.HEADERS_RECEIVED;
this.eventBus.trigger('readystatechange');
this.responseType = options.responseType || "";
this.responseURL = options.responseURL || null;
this.readyState = FakeXMLHttpRequest.LOADING;
this.eventBus.trigger('readystatechange');
},
streamData: function(data) {
if (this.readyState !== FakeXMLHttpRequest.LOADING) {
throw new Error("FakeXMLHttpRequest is not loading yet");
}
this.responseText += data;
this.responseXML = getResponseXml(this.responseText, this.getResponseHeader('content-type') || '');
if (this.responseXML) {
this.responseType = 'document';
}
this.response = this.responseValue();
this.eventBus.trigger('readystatechange');
this.eventBus.trigger('progress');
},
cancelStream: function () {
if (this.readyState === FakeXMLHttpRequest.DONE) {
throw new Error("FakeXMLHttpRequest already completed");
}
this.status = 0;
this.statusText = "";
this.readyState = FakeXMLHttpRequest.DONE;
this.eventBus.trigger('readystatechange');
this.eventBus.trigger('progress');
this.eventBus.trigger('loadend');
},
completeStream: function(status) {
if (this.readyState === FakeXMLHttpRequest.DONE) {
throw new Error("FakeXMLHttpRequest already completed");
}
this.status = status || 200;
this.statusText = "";
this.readyState = FakeXMLHttpRequest.DONE;
this.eventBus.trigger('readystatechange');
this.eventBus.trigger('progress');
this.eventBus.trigger('loadend');
}

@@ -636,7 +683,11 @@ });

var normalizeQuery = function(query) {
return query ? query.split('&').sort().join('&') : undefined;
};
var timeoutRequest = function(request) {
request.responseTimeout();
};
function RequestStub(url, stubData, method) {
var normalizeQuery = function(query) {
return query ? query.split('&').sort().join('&') : undefined;
};
if (url instanceof RegExp) {

@@ -653,49 +704,33 @@ this.url = url;

this.method = method;
}
this.andReturn = function(options) {
this.action = RETURN;
this.status = (typeof options.status !== 'undefined') ? options.status : 200;
this.statusText = options.statusText;
RequestStub.prototype = {
andReturn: function(options) {
options.status = (typeof options.status !== 'undefined') ? options.status : 200;
this.handleRequest = function(request) {
request.respondWith(options);
};
},
this.contentType = options.contentType;
this.response = options.response;
this.responseText = options.responseText;
this.responseHeaders = options.responseHeaders;
this.responseURL = options.responseURL;
};
this.isReturn = function() {
return this.action === RETURN;
};
this.andError = function(options) {
andError: function(options) {
if (!options) {
options = {};
}
this.action = ERROR;
this.status = options.status || 500;
};
options.status = options.status || 500;
this.handleRequest = function(request) {
request.responseError(options);
};
},
this.isError = function() {
return this.action === ERROR;
};
andTimeout: function() {
this.handleRequest = timeoutRequest;
},
this.andTimeout = function() {
this.action = TIMEOUT;
};
andCallFunction: function(functionToCall) {
this.handleRequest = function(request) {
functionToCall(request);
};
},
this.isTimeout = function() {
return this.action === TIMEOUT;
};
this.andCallFunction = function(functionToCall) {
this.action = CALL;
this.functionToCall = functionToCall;
};
this.isCallFunction = function() {
return this.action === CALL;
};
this.matches = function(fullUrl, data, method) {
matches: function(fullUrl, data, method) {
var urlMatches = false;

@@ -718,4 +753,4 @@ fullUrl = fullUrl.toString();

return urlMatches && dataMatches && (!this.method || this.method === method);
};
}
}
};

@@ -722,0 +757,0 @@ return RequestStub;

{
"name": "jasmine-ajax",
"description": "A library for faking Ajax responses in your Jasmine suite",
"version": "3.4.0",
"version": "4.0.0",
"main": "lib/mock-ajax.js",

@@ -6,0 +6,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc