nock 8.2.1 → 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.
Files changed (34) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/lib/request_overrider.js +1 -1
  3. package/package.json +1 -1
  4. package/tests/test_intercept.js +28 -25
  5. package/.npmignore +0 -3
  6. package/.nyc_output/01e0d97d49dffb18a00bafa55e39110e.json +0 -1
  7. package/.nyc_output/05c82e26b102460bfb44dd96e137e0af.json +0 -1
  8. package/.nyc_output/12565d5c5477f67f304b77fab8c99ede.json +0 -1
  9. package/.nyc_output/25352e5b7cdd8bf4ea92bf1590556ec9.json +0 -1
  10. package/.nyc_output/265a00999489a2f1214cf8ee5ce42d67.json +0 -1
  11. package/.nyc_output/30496580ece3954eea513694f531f0e2.json +0 -1
  12. package/.nyc_output/3103ebbbd51c147d559927131bc56a02.json +0 -1
  13. package/.nyc_output/39abc08c82c197dcf31fd07aa5be78c8.json +0 -1
  14. package/.nyc_output/4df419959689d29306951dfc8b95cdb0.json +0 -1
  15. package/.nyc_output/57b304fe4ecacde0239280a6b7190922.json +0 -1
  16. package/.nyc_output/5b6085d5ce3a165e4d2de992c94cb017.json +0 -1
  17. package/.nyc_output/5fbed533ac983f3d05d728821f5df928.json +0 -1
  18. package/.nyc_output/66f77d8474a4326feda82736dbb5fcbf.json +0 -1
  19. package/.nyc_output/8057b526499964b5111d1a492232a95b.json +0 -1
  20. package/.nyc_output/83fb29ccb0c7f22fe04b216040e3c366.json +0 -1
  21. package/.nyc_output/a20cec79a5acef35d4c407435b9eddc8.json +0 -1
  22. package/.nyc_output/a2153ff2ef2490fe5b3ecff30e4acbf3.json +0 -1
  23. package/.nyc_output/beb3f6960bdce3b07fa75af04e189a03.json +0 -1
  24. package/.nyc_output/c31f5f1ec133e6c0b4304f5627246ea1.json +0 -1
  25. package/.nyc_output/cbbbba5d50ea6259250f148e0da9744c.json +0 -1
  26. package/.nyc_output/cd8e8e5c8d5e6504082c68f621675886.json +0 -1
  27. package/.nyc_output/e10459eb64ba6f4b57dc870703952407.json +0 -1
  28. package/.nyc_output/e1dc0ec3d9960b860cd8150dcf6231c2.json +0 -1
  29. package/.nyc_output/e39a8b037b4a9952429745d54799abd3.json +0 -1
  30. package/.nyc_output/ec0c5c9ffa0f012e5caba239a9859640.json +0 -1
  31. package/.nyc_output/ec97b0ace89a0f96160534425b7e54ff.json +0 -1
  32. package/.nyc_output/f76caf0ad5c4c13b707345f27f96e44b.json +0 -1
  33. package/mb.log +0 -2
  34. package/tests/browserify-public/browserify-bundle.js +0 -35214
package/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 8.2.2 / 2017-10-15
2
+ ==================
3
+
4
+ * Set `this` to request on socket event. [#993](https://github.com/node-nock/nock/pull/993)
5
+
1
6
  8.2.0 / 2016-10-23
2
7
  ==================
3
8
 
@@ -192,7 +192,7 @@ function RequestOverrider(req, options, interceptors, remove, cb) {
192
192
  req.once = req.on = function(event, listener) {
193
193
  // emit a fake socket.
194
194
  if (event == 'socket') {
195
- listener(req.socket);
195
+ listener.call(req, req.socket);
196
196
  req.socket.emit('connect', req.socket);
197
197
  req.socket.emit('secureConnect', req.socket);
198
198
  }
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "testing",
8
8
  "isolation"
9
9
  ],
10
- "version": "8.2.1",
10
+ "version": "8.2.2",
11
11
  "author": "Pedro Teixeira <pedro.teixeira@gmail.com>",
12
12
  "contributors": [
13
13
  {
@@ -3567,35 +3567,37 @@ test('define() works with binary buffers', function(t) {
3567
3567
 
3568
3568
  });
3569
3569
 
3570
- test('issue #163 - Authorization header isn\'t mocked', function(t) {
3571
- nock.enableNetConnect();
3572
- function makeRequest(cb) {
3573
- var r = http.request(
3574
- {
3575
- hostname: 'www.example.com',
3576
- path: '/',
3577
- method: 'GET',
3578
- auth: 'foo:bar'
3579
- },
3580
- function(res) {
3581
- cb(res.req._headers);
3582
- }
3583
- );
3584
- r.end();
3585
- }
3570
+ if (process.versions.node >= '0.11' ) {
3571
+ test('issue #163 - Authorization header isn\'t mocked', function(t) {
3572
+ nock.enableNetConnect();
3573
+ function makeRequest(cb) {
3574
+ var r = http.request(
3575
+ {
3576
+ hostname: 'www.example.com',
3577
+ path: '/',
3578
+ method: 'GET',
3579
+ auth: 'foo:bar'
3580
+ },
3581
+ function(res) {
3582
+ cb(res.req._headers);
3583
+ }
3584
+ );
3585
+ r.end();
3586
+ }
3586
3587
 
3587
- makeRequest(function(headers) {
3588
- var n = nock('http://www.example.com', {
3589
- reqheaders: { 'authorization': 'Basic Zm9vOmJhcg==' }
3590
- }).get('/').reply(200);
3588
+ makeRequest(function(headers) {
3589
+ var n = nock('http://www.example.com', {
3590
+ reqheaders: { 'authorization': 'Basic Zm9vOmJhcg==' }
3591
+ }).get('/').reply(200);
3591
3592
 
3592
- makeRequest(function(nockHeader) {
3593
- n.done();
3594
- t.equivalent(headers, nockHeader);
3595
- t.end();
3593
+ makeRequest(function(nockHeader) {
3594
+ n.done();
3595
+ t.equivalent(headers, nockHeader);
3596
+ t.end();
3597
+ });
3596
3598
  });
3597
3599
  });
3598
- });
3600
+ }
3599
3601
 
3600
3602
  test('define() uses reqheaders', function(t) {
3601
3603
  var nockDef = {
@@ -4225,6 +4227,7 @@ test('request emits socket', function(t) {
4225
4227
 
4226
4228
  var req = http.get('http://gotzsocketz.com');
4227
4229
  req.once('socket', function(socket) {
4230
+ t.equal(this, req);
4228
4231
  t.type(socket, Object);
4229
4232
  t.type(socket.getPeerCertificate(), 'string');
4230
4233
  t.end();
package/.npmignore DELETED
@@ -1,3 +0,0 @@
1
- node_modules
2
- .gitignore
3
- coverage