nock 7.6.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -33
- package/README.md +1 -1
- package/coverage/coverage.json +1 -1
- package/coverage/lcov-report/base.css +143 -113
- package/coverage/lcov-report/index.html +55 -35
- package/coverage/lcov-report/nock/index.html +46 -26
- package/coverage/lcov-report/nock/index.js.html +45 -25
- package/coverage/lcov-report/nock/lib/back.js.html +144 -121
- package/coverage/lcov-report/nock/lib/common.js.html +185 -165
- package/coverage/lcov-report/nock/lib/delayed_body.js.html +61 -41
- package/coverage/lcov-report/nock/lib/global_emitter.js.html +42 -22
- package/coverage/lcov-report/nock/lib/index.html +111 -91
- package/coverage/lcov-report/nock/lib/intercept.js.html +219 -244
- package/coverage/lcov-report/nock/lib/interceptor.js.html +309 -259
- package/coverage/lcov-report/nock/lib/match_body.js.html +76 -56
- package/coverage/lcov-report/nock/lib/mixin.js.html +50 -30
- package/coverage/lcov-report/nock/lib/request_overrider.js.html +285 -265
- package/coverage/lcov-report/nock/lib/scope.js.html +204 -184
- package/coverage/lcov-report/nock/lib/socket.js.html +89 -54
- package/coverage/lcov-report/sorter.js +4 -2
- package/coverage/lcov.info +1225 -1213
- package/lib/common.js +2 -2
- package/lib/intercept.js +8 -23
- package/lib/request_overrider.js +1 -1
- package/lib/socket.js +6 -1
- package/package.json +14 -13
- package/tests/browserify-public/browserify-bundle.js +26754 -23296
- package/tests/test_back.js +14 -26
- package/tests/test_back_2.js +10 -5
- package/tests/test_events.js +19 -6
- package/tests/test_intercept.js +168 -146
package/lib/common.js
CHANGED
|
@@ -157,7 +157,7 @@ var restoreOverriddenRequests = function() {
|
|
|
157
157
|
override.module.request = override.request;
|
|
158
158
|
debug('- restored request for', proto);
|
|
159
159
|
}
|
|
160
|
-
})
|
|
160
|
+
});
|
|
161
161
|
requestOverride = [];
|
|
162
162
|
};
|
|
163
163
|
|
|
@@ -244,7 +244,7 @@ var deleteHeadersField = function(headers, fieldNameToDelete) {
|
|
|
244
244
|
// We don't stop here but continue in order to remove *all* matching field names
|
|
245
245
|
// (even though if seen regorously there shouldn't be any)
|
|
246
246
|
}
|
|
247
|
-
})
|
|
247
|
+
});
|
|
248
248
|
|
|
249
249
|
};
|
|
250
250
|
|
package/lib/intercept.js
CHANGED
|
@@ -110,31 +110,16 @@ function add(key, interceptor, scope, scopeOptions, host) {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
function remove(interceptor) {
|
|
113
|
-
if (interceptor.__nock_scope.shouldPersist()) {
|
|
113
|
+
if (interceptor.__nock_scope.shouldPersist() || --interceptor.counter > 0) {
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
interceptor.
|
|
118
|
-
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
var key = interceptor._key.split(' '),
|
|
123
|
-
u = url.parse(key[1]),
|
|
124
|
-
hostKey = u.protocol + '//' + u.host,
|
|
125
|
-
interceptors = allInterceptors[hostKey] && allInterceptors[hostKey].scopes,
|
|
126
|
-
thisInterceptor;
|
|
127
|
-
|
|
128
|
-
if (interceptors) {
|
|
129
|
-
for(var i = 0; i < interceptors.length; i++) {
|
|
130
|
-
thisInterceptor = interceptors[i];
|
|
131
|
-
if (thisInterceptor === interceptor) {
|
|
132
|
-
interceptors.splice(i, 1);
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
117
|
+
var basePath = interceptor.basePath;
|
|
118
|
+
var interceptors = allInterceptors[basePath] && allInterceptors[basePath].scopes || [];
|
|
136
119
|
|
|
137
|
-
|
|
120
|
+
interceptors.some(function (thisInterceptor, i) {
|
|
121
|
+
return (thisInterceptor === interceptor) ? interceptors.splice(i, 1) : false;
|
|
122
|
+
});
|
|
138
123
|
}
|
|
139
124
|
|
|
140
125
|
function removeAll() {
|
|
@@ -246,7 +231,7 @@ function overrideClientRequest() {
|
|
|
246
231
|
if (http.OutgoingMessage) http.OutgoingMessage.call(this);
|
|
247
232
|
|
|
248
233
|
// Filter the interceptors per request options.
|
|
249
|
-
var interceptors = interceptorsFor(options)
|
|
234
|
+
var interceptors = interceptorsFor(options);
|
|
250
235
|
|
|
251
236
|
if (isOn() && interceptors) {
|
|
252
237
|
debug('using', interceptors.length, 'interceptors');
|
|
@@ -383,7 +368,7 @@ function activate() {
|
|
|
383
368
|
}
|
|
384
369
|
return req;
|
|
385
370
|
} else {
|
|
386
|
-
globalEmitter.emit('no match',
|
|
371
|
+
globalEmitter.emit('no match', options);
|
|
387
372
|
if (isOff() || isEnabledForNetConnect(options)) {
|
|
388
373
|
return overriddenRequest(options, callback);
|
|
389
374
|
} else {
|
package/lib/request_overrider.js
CHANGED
|
@@ -235,7 +235,7 @@ function RequestOverrider(req, options, interceptors, remove, cb) {
|
|
|
235
235
|
// For correct matching we need to have correct request headers - if these were specified.
|
|
236
236
|
setRequestHeaders(req, options, interceptor);
|
|
237
237
|
});
|
|
238
|
-
|
|
238
|
+
|
|
239
239
|
interceptor = _.find(interceptors, function(interceptor) {
|
|
240
240
|
return interceptor.match(options, requestBody);
|
|
241
241
|
});
|
package/lib/socket.js
CHANGED
|
@@ -21,10 +21,10 @@ function Socket(options) {
|
|
|
21
21
|
|
|
22
22
|
this.writable = true;
|
|
23
23
|
this.readable = true;
|
|
24
|
+
this.destroyed = false;
|
|
24
25
|
|
|
25
26
|
this.setNoDelay = noop;
|
|
26
27
|
this.setKeepAlive = noop;
|
|
27
|
-
this.destroy = noop;
|
|
28
28
|
this.resume = noop;
|
|
29
29
|
|
|
30
30
|
// totalDelay that has already been applied to the current
|
|
@@ -60,5 +60,10 @@ Socket.prototype.getPeerCertificate = function getPeerCertificate() {
|
|
|
60
60
|
return new Buffer((Math.random() * 10000 + Date.now()).toString()).toString('base64');
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
Socket.prototype.destroy = function destroy() {
|
|
64
|
+
this.destroyed = true;
|
|
65
|
+
this.readable = this.writable = false;
|
|
66
|
+
};
|
|
67
|
+
|
|
63
68
|
function noop() {}
|
|
64
69
|
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"testing",
|
|
8
8
|
"isolation"
|
|
9
9
|
],
|
|
10
|
-
"version": "
|
|
10
|
+
"version": "8.0.0",
|
|
11
11
|
"author": "Pedro Teixeira <pedro.teixeira@gmail.com>",
|
|
12
12
|
"contributors": [
|
|
13
13
|
{
|
|
@@ -167,29 +167,30 @@
|
|
|
167
167
|
"debug": "^2.2.0",
|
|
168
168
|
"deep-equal": "^1.0.0",
|
|
169
169
|
"json-stringify-safe": "^5.0.1",
|
|
170
|
-
"lodash": "^
|
|
170
|
+
"lodash": "^4.8.2",
|
|
171
171
|
"mkdirp": "^0.5.0",
|
|
172
|
-
"propagate": "0.
|
|
172
|
+
"propagate": "0.4.0",
|
|
173
173
|
"qs": "^6.0.2"
|
|
174
174
|
},
|
|
175
175
|
"devDependencies": {
|
|
176
|
+
"async": "^1.5.2",
|
|
176
177
|
"aws-sdk": "^2.0.15",
|
|
177
|
-
"browserify": "^
|
|
178
|
+
"browserify": "^13.0.0",
|
|
178
179
|
"coveralls": "^2.11.2",
|
|
179
|
-
"hyperquest": "^
|
|
180
|
+
"hyperquest": "^1.3.0",
|
|
180
181
|
"isomorphic-fetch": "^2.2.0",
|
|
181
|
-
"istanbul": "^0.
|
|
182
|
+
"istanbul": "^0.4.2",
|
|
182
183
|
"jshint": "^2.5.6",
|
|
183
|
-
"needle": "^0.
|
|
184
|
+
"needle": "^1.0.0",
|
|
184
185
|
"node-static": "^0.7.7",
|
|
185
|
-
"pre-commit": "
|
|
186
|
-
"request": "2.
|
|
187
|
-
"request-promise": "^0.
|
|
188
|
-
"restify": "^
|
|
189
|
-
"restler": "3.
|
|
186
|
+
"pre-commit": "1.1.2",
|
|
187
|
+
"request": "2.70.0",
|
|
188
|
+
"request-promise": "^2.0.1",
|
|
189
|
+
"restify": "^4.0.4",
|
|
190
|
+
"restler": "3.4.0",
|
|
190
191
|
"rimraf": "^2.3.2",
|
|
191
192
|
"superagent": "^1.4.0",
|
|
192
|
-
"tap": "^
|
|
193
|
+
"tap": "^5.7.0",
|
|
193
194
|
"zombie": "^4.2.1"
|
|
194
195
|
},
|
|
195
196
|
"scripts": {
|