File tree Expand file tree Collapse file tree 5 files changed +9
-8
lines changed Expand file tree Collapse file tree 5 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 1
-
1
+ var window = require ( 'global' ) ;
2
2
var MockXMLHttpRequest = require ( './lib/MockXMLHttpRequest' ) ;
3
3
var real = window . XMLHttpRequest ;
4
4
var mock = MockXMLHttpRequest ;
@@ -85,4 +85,4 @@ module.exports = {
85
85
return this . mock ( 'PUT' , url , fn ) ;
86
86
}
87
87
88
- } ;
88
+ } ;
Original file line number Diff line number Diff line change @@ -74,4 +74,4 @@ MockRequest.prototype.body = function(body) {
74
74
}
75
75
} ;
76
76
77
- module . exports = MockRequest ;
77
+ module . exports = MockRequest ;
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ MockXMLHttpRequest.prototype.send = function(data) {
134
134
135
135
self . readyState = MockXMLHttpRequest . STATE_LOADING ;
136
136
137
- self . _sendTimeout = window . setTimeout ( function ( ) {
137
+ self . _sendTimeout = setTimeout ( function ( ) {
138
138
139
139
var response = MockXMLHttpRequest . handle ( new MockRequest ( self ) ) ;
140
140
@@ -145,7 +145,7 @@ MockXMLHttpRequest.prototype.send = function(data) {
145
145
if ( timeout ) {
146
146
147
147
//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
148
- self . _sendTimeout = window . setTimeout ( function ( ) {
148
+ self . _sendTimeout = setTimeout ( function ( ) {
149
149
self . readyState = MockXMLHttpRequest . STATE_DONE ;
150
150
self . trigger ( 'timeout' ) ;
151
151
} , typeof ( timeout ) === 'number' ? timeout : self . timeout + 1 ) ;
@@ -178,7 +178,7 @@ MockXMLHttpRequest.prototype.send = function(data) {
178
178
} ;
179
179
180
180
MockXMLHttpRequest . prototype . abort = function ( ) {
181
- window . clearTimeout ( this . _sendTimeout ) ;
181
+ clearTimeout ( this . _sendTimeout ) ;
182
182
183
183
if ( this . readyState > MockXMLHttpRequest . STATE_UNSENT && this . readyState < MockXMLHttpRequest . STATE_DONE ) {
184
184
this . readyState = MockXMLHttpRequest . STATE_UNSENT ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " xhr-mock" ,
3
- "version" : " 1.4.1 " ,
3
+ "version" : " 1.5.0 " ,
4
4
"description" : " Utility for mocking XMLHttpRequests in the browser." ,
5
5
"keywords" : [
6
6
" mock" ,
20
20
},
21
21
"devDependencies" : {
22
22
"browserify" : " ^11.0.1" ,
23
+ "global" : " ^4.3.0" ,
23
24
"mochify" : " ^2.13.0" ,
24
25
"superagent" : " ^1.3.0"
25
26
},
29
30
},
30
31
"license" : " MIT"
31
32
}
32
-
Original file line number Diff line number Diff line change
1
+ var window = require ( 'global' ) ;
1
2
var assert = require ( 'assert' ) ;
2
3
var mock = require ( '..' ) ;
3
4
You can’t perform that action at this time.
0 commit comments