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.0.0 to 3.1.0

release_notes/v3.1.0.md

2

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

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

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

@@ -40,3 +40,4 @@

$ajax.ParamParser = jRequire.AjaxParamParser();
$ajax.fakeRequest = jRequire.AjaxFakeRequest();
$ajax.eventBus = jRequire.AjaxEventBus();
$ajax.fakeRequest = jRequire.AjaxFakeRequest($ajax.eventBus);
$ajax.MockAjax = jRequire.MockAjax($ajax);

@@ -47,3 +48,53 @@

getJasmineRequireObj().AjaxFakeRequest = function() {
getJasmineRequireObj().AjaxEventBus = function() {
function EventBus() {
this.eventList = {};
}
function ensureEvent(eventList, name) {
eventList[name] = eventList[name] || [];
return eventList[name];
}
function findIndex(list, thing) {
if (list.indexOf) {
return list.indexOf(thing);
}
for(var i = 0; i < list.length; i++) {
if (thing === list[i]) {
return i;
}
}
return -1;
}
EventBus.prototype.addEventListener = function(event, callback) {
ensureEvent(this.eventList, event).push(callback);
};
EventBus.prototype.removeEventListener = function(event, callback) {
var index = findIndex(this.eventList[event], callback);
if (index >= 0) {
this.eventList[event].splice(index, 1);
}
};
EventBus.prototype.trigger = function(event) {
var eventListeners = this.eventList[event];
if(eventListeners){
for(var i = 0; i < eventListeners.length; i++){
eventListeners[i]();
}
}
};
return function() {
return new EventBus();
};
};
getJasmineRequireObj().AjaxFakeRequest = function(eventBusFactory) {
function extend(destination, source, propertiesToSkip) {

@@ -77,11 +128,9 @@ propertiesToSkip = propertiesToSkip || [];

function initializeEvents(xhr) {
return {
'loadstart': wrapProgressEvent(xhr, 'onloadstart'),
'load': wrapProgressEvent(xhr, 'onload'),
'loadend': wrapProgressEvent(xhr, 'onloadend'),
'progress': wrapProgressEvent(xhr, 'onprogress'),
'error': wrapProgressEvent(xhr, 'onerror'),
'abort': wrapProgressEvent(xhr, 'onabort'),
'timeout': wrapProgressEvent(xhr, 'ontimeout')
};
xhr.eventBus.addEventListener('loadstart', wrapProgressEvent(xhr, 'onloadstart'));
xhr.eventBus.addEventListener('load', wrapProgressEvent(xhr, 'onload'));
xhr.eventBus.addEventListener('loadend', wrapProgressEvent(xhr, 'onloadend'));
xhr.eventBus.addEventListener('progress', wrapProgressEvent(xhr, 'onprogress'));
xhr.eventBus.addEventListener('error', wrapProgressEvent(xhr, 'onerror'));
xhr.eventBus.addEventListener('abort', wrapProgressEvent(xhr, 'onabort'));
xhr.eventBus.addEventListener('timeout', wrapProgressEvent(xhr, 'ontimeout'));
}

@@ -102,3 +151,4 @@

requestTracker.track(this);
this.events = initializeEvents(this);
this.eventBus = eventBusFactory();
initializeEvents(this);
this.requestHeaders = {};

@@ -188,5 +238,5 @@ this.overriddenMimeType = null;

this.onreadystatechange();
this.events.progress();
this.events.abort();
this.events.loadend();
this.eventBus.trigger('progress');
this.eventBus.trigger('abort');
this.eventBus.trigger('loadend');
},

@@ -207,11 +257,9 @@

addEventListener: function(event, callback) {
var existingCallback = this.events[event],
self = this;
this.events[event] = function() {
callback.apply(self);
existingCallback();
};
addEventListener: function() {
this.eventBus.addEventListener.apply(this.eventBus, arguments);
},
removeEventListener: function(event, callback) {
this.eventBus.removeEventListener.apply(this.eventBus, arguments);
},

@@ -223,3 +271,3 @@ status: null,

this.readyState = 2;
this.events.loadstart();
this.eventBus.trigger('loadstart');
this.onreadystatechange();

@@ -314,5 +362,5 @@

this.onreadystatechange();
this.events.progress();
this.events.load();
this.events.loadend();
this.eventBus.trigger('progress');
this.eventBus.trigger('load');
this.eventBus.trigger('loadend');
},

@@ -327,5 +375,5 @@

this.onreadystatechange('timeout');
this.events.progress();
this.events.timeout();
this.events.loadend();
this.eventBus.trigger('progress');
this.eventBus.trigger('timeout');
this.eventBus.trigger('loadend');
},

@@ -339,5 +387,5 @@

this.onreadystatechange();
this.events.progress();
this.events.error();
this.events.loadend();
this.eventBus.trigger('progress');
this.eventBus.trigger('error');
this.eventBus.trigger('loadend');
}

@@ -479,2 +527,3 @@ });

this.responseText = options.responseText;
this.responseHeaders = options.responseHeaders;
};

@@ -481,0 +530,0 @@

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

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

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