File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,11 @@ function remove(interceptor) {
123123}
124124
125125function removeAll ( ) {
126+ Object . keys ( allInterceptors ) . forEach ( function ( key ) {
127+ allInterceptors [ key ] . scopes . forEach ( function ( interceptor ) {
128+ interceptor . scope . keyedInterceptors = { } ;
129+ } ) ;
130+ } ) ;
126131 allInterceptors = { } ;
127132}
128133
Original file line number Diff line number Diff line change @@ -2249,6 +2249,23 @@ test('clean all works', function(t) {
22492249
22502250} ) ;
22512251
2252+ test ( 'clean all should remove pending mocks from all scopes' , function ( t ) {
2253+ var scope1 = nock ( 'http://example.org' )
2254+ . get ( '/somepath' )
2255+ . reply ( 200 , 'hey' ) ;
2256+ t . deepEqual ( scope1 . pendingMocks ( ) , [ 'GET http://example.org:80/somepath' ] ) ;
2257+ var scope2 = nock ( 'http://example.com' )
2258+ . get ( '/somepath' )
2259+ . reply ( 200 , 'hey' ) ;
2260+ t . deepEqual ( scope2 . pendingMocks ( ) , [ 'GET http://example.com:80/somepath' ] ) ;
2261+
2262+ nock . cleanAll ( ) ;
2263+
2264+ t . deepEqual ( scope1 . pendingMocks ( ) , [ ] ) ;
2265+ t . deepEqual ( scope2 . pendingMocks ( ) , [ ] ) ;
2266+ t . end ( ) ;
2267+ } ) ;
2268+
22522269test ( 'is done works' , function ( t ) {
22532270 var scope = nock ( 'http://amazon.com' )
22542271 . get ( '/nonexistent' )
You can’t perform that action at this time.
0 commit comments