nock 8.0.0 → 8.2.2
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/.travis.yml +1 -0
- package/CHANGELOG.md +107 -114
- package/README.md +103 -42
- package/lib/common.js +15 -1
- package/lib/intercept.js +24 -11
- package/lib/interceptor.js +21 -22
- package/lib/match_body.js +1 -1
- package/lib/recorder.js +6 -3
- package/lib/request_overrider.js +3 -3
- package/lib/scope.js +30 -28
- package/package.json +10 -7
- package/tests/test_back.js +5 -2
- package/tests/test_body_match.js +40 -0
- package/tests/test_browserify.js +54 -52
- package/tests/test_intercept.js +195 -47
- package/tests/test_isomorphic_fetch.js +45 -45
- package/.npmignore +0 -2
- package/coverage/coverage.json +0 -1
- package/coverage/lcov-report/base.css +0 -212
- package/coverage/lcov-report/index.html +0 -106
- package/coverage/lcov-report/nock/index.html +0 -93
- package/coverage/lcov-report/nock/index.js.html +0 -98
- package/coverage/lcov-report/nock/lib/back.js.html +0 -1022
- package/coverage/lcov-report/nock/lib/common.js.html +0 -1070
- package/coverage/lcov-report/nock/lib/delayed_body.js.html +0 -305
- package/coverage/lcov-report/nock/lib/global_emitter.js.html +0 -71
- package/coverage/lcov-report/nock/lib/index.html +0 -223
- package/coverage/lcov-report/nock/lib/intercept.js.html +0 -1253
- package/coverage/lcov-report/nock/lib/interceptor.js.html +0 -1670
- package/coverage/lcov-report/nock/lib/match_body.js.html +0 -275
- package/coverage/lcov-report/nock/lib/mixin.js.html +0 -107
- package/coverage/lcov-report/nock/lib/recorder.js.html +0 -1323
- package/coverage/lcov-report/nock/lib/request_overrider.js.html +0 -1643
- package/coverage/lcov-report/nock/lib/scope.js.html +0 -1133
- package/coverage/lcov-report/nock/lib/socket.js.html +0 -272
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -1
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -158
- package/coverage/lcov.info +0 -2428
- package/tests/browserify-public/browserify-bundle.js +0 -34332
- package/tests/test.js +0 -32
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
if (process.versions.node >= '0.11' ) {
|
|
4
|
+
var nock = require('../');
|
|
5
|
+
var test = require('tap').test;
|
|
6
|
+
var fetch = require('isomorphic-fetch');
|
|
6
7
|
|
|
7
|
-
test("basic match works", function(t) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
test("basic match works", function(t) {
|
|
9
|
+
var scope = nock('http://isomorphicfetchland.com').
|
|
10
|
+
get('/path').
|
|
11
|
+
reply(200, 'somedata');
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
fetch('http://isomorphicfetchland.com/path').
|
|
14
|
+
then(function(res) {
|
|
15
|
+
return res.text();
|
|
16
|
+
}).
|
|
17
|
+
then(function(text) {
|
|
18
|
+
scope.done();
|
|
19
|
+
t.equal(text, 'somedata', "response should match");
|
|
20
|
+
t.end();
|
|
21
|
+
}).
|
|
22
|
+
catch(function(err) {
|
|
23
|
+
throw err;
|
|
24
|
+
});
|
|
23
25
|
});
|
|
24
|
-
});
|
|
25
26
|
|
|
26
|
-
test("string-based reqheaders match works", function(t) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
test("string-based reqheaders match works", function(t) {
|
|
28
|
+
var scope = nock('http://isomorphicfetchland.com', {
|
|
29
|
+
reqheaders: {
|
|
30
|
+
'header': 'header value',
|
|
31
|
+
}
|
|
32
|
+
}).
|
|
33
|
+
get('/path2').
|
|
34
|
+
reply(200, 'somemoardata');
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
fetch('http://isomorphicfetchland.com/path2', {
|
|
37
|
+
headers: {
|
|
38
|
+
'header': 'header value',
|
|
39
|
+
}
|
|
40
|
+
}).
|
|
41
|
+
then(function(res) {
|
|
42
|
+
return res.text();
|
|
43
|
+
}).
|
|
44
|
+
then(function(text) {
|
|
45
|
+
scope.done();
|
|
46
|
+
t.equal(text, 'somemoardata', "response should match");
|
|
47
|
+
t.end();
|
|
48
|
+
}).
|
|
49
|
+
catch(function(err) {
|
|
50
|
+
throw err;
|
|
51
|
+
});
|
|
50
52
|
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
}
|
package/.npmignore
DELETED