Comparing version 0.14.1 to 0.14.2
@@ -17,6 +17,7 @@ var RequestOverrider = require('./request_overrider'), | ||
function add(key, interceptor) { | ||
function add(key, interceptor, scope) { | ||
if (! allInterceptors.hasOwnProperty(key)) { | ||
allInterceptors[key] = []; | ||
} | ||
interceptor.__nock_scope = scope; | ||
allInterceptors[key].push(interceptor); | ||
@@ -26,2 +27,4 @@ } | ||
function remove(interceptor) { | ||
if (interceptor.__nock_scope.shouldPersist()) return; | ||
var key = interceptor._key.split(' '), | ||
@@ -28,0 +31,0 @@ u = url.parse(key[1]), |
@@ -28,3 +28,3 @@ var path = require('path') | ||
function add(key, interceptor) { | ||
function add(key, interceptor, scope) { | ||
if (! interceptors.hasOwnProperty(key)) { | ||
@@ -34,3 +34,3 @@ interceptors[key] = []; | ||
interceptors[key].push(interceptor); | ||
globalIntercept(basePath, interceptor); | ||
globalIntercept(basePath, interceptor, scope); | ||
} | ||
@@ -95,3 +95,3 @@ | ||
this.body = body; | ||
add(key, this); | ||
add(key, this, scope); | ||
return scope; | ||
@@ -309,2 +309,6 @@ } | ||
} | ||
function shouldPersist() { | ||
return persist; | ||
} | ||
@@ -326,2 +330,3 @@ scope = { | ||
, persist: _persist | ||
, shouldPersist: shouldPersist | ||
}; | ||
@@ -328,0 +333,0 @@ |
{ "name" : "nock" | ||
, "description" : "HTTP Server mocking for Node.js" | ||
, "tags" : ["Mock", "HTTP", "testing", "isolation"] | ||
, "version" : "0.14.1" | ||
, "version" : "0.14.2" | ||
, "author" : "Pedro Teixeira <pedro.teixeira@gmail.com>" | ||
@@ -6,0 +6,0 @@ , "contributors" : |
@@ -9,2 +9,3 @@ var nock = require('../.') | ||
tap.test("get gets mocked", function(t) { | ||
@@ -1584,4 +1585,8 @@ var dataCalled = false | ||
t.ok(! scope.isDone()); | ||
t.end(); | ||
console.log('Hey'); | ||
http.get('http://persisssists.con/', function(res) { | ||
t.ok(! scope.isDone()); | ||
t.end(); | ||
}).end(); | ||
}).end(); | ||
}); | ||
}); |
69459
2020