Skip to content

Commit

Permalink
Merge branch 'orbitet push origin master:orbiteleven-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
James Newell committed Dec 1, 2015
2 parents 8d7300a + d09e939 commit b150177
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

var window = require('global');
var MockXMLHttpRequest = require('./lib/MockXMLHttpRequest');
var real = window.XMLHttpRequest;
var mock = MockXMLHttpRequest;
Expand Down Expand Up @@ -85,4 +85,4 @@ module.exports = {
return this.mock('PUT', url, fn);
}

};
};
2 changes: 1 addition & 1 deletion lib/MockRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ MockRequest.prototype.body = function(body) {
}
};

module.exports = MockRequest;
module.exports = MockRequest;
6 changes: 3 additions & 3 deletions lib/MockXMLHttpRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ MockXMLHttpRequest.prototype.send = function(data) {

self.readyState = MockXMLHttpRequest.STATE_LOADING;

self._sendTimeout = window.setTimeout(function() {
self._sendTimeout = setTimeout(function() {

var response = MockXMLHttpRequest.handle(new MockRequest(self));

Expand All @@ -145,7 +145,7 @@ MockXMLHttpRequest.prototype.send = function(data) {
if (timeout) {

//trigger a timeout event because the request timed out - wait for the timeout time because many libs like jquery and superagent use setTimeout to detect the error type
self._sendTimeout = window.setTimeout(function() {
self._sendTimeout = setTimeout(function() {
self.readyState = MockXMLHttpRequest.STATE_DONE;
self.trigger('timeout');
}, typeof(timeout) === 'number' ? timeout : self.timeout+1);
Expand Down Expand Up @@ -178,7 +178,7 @@ MockXMLHttpRequest.prototype.send = function(data) {
};

MockXMLHttpRequest.prototype.abort = function() {
window.clearTimeout(this._sendTimeout);
clearTimeout(this._sendTimeout);

if (this.readyState > MockXMLHttpRequest.STATE_UNSENT && this.readyState < MockXMLHttpRequest.STATE_DONE) {
this.readyState = MockXMLHttpRequest.STATE_UNSENT;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xhr-mock",
"version": "1.4.1",
"version": "1.5.0",
"description": "Utility for mocking XMLHttpRequests in the browser.",
"keywords": [
"mock",
Expand All @@ -20,6 +20,7 @@
},
"devDependencies": {
"browserify": "^11.0.1",
"global": "^4.3.0",
"mochify": "^2.13.0",
"superagent": "^1.3.0"
},
Expand All @@ -29,4 +30,3 @@
},
"license": "MIT"
}

1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var window = require('global');
var assert = require('assert');
var mock = require('..');

Expand Down

0 comments on commit b150177

Please sign in to comment.