@@ -101,8 +101,8 @@ describe('MockAdapter basics', function() {
101101 it ( 'accepts a callback that returns an axios request' , function ( ) {
102102 mock
103103 . onGet ( '/bar' )
104- . reply ( 200 , { foo : 'bar' } )
105- . onGet ( '/foo' )
104+ . reply ( 200 , { foo : 'bar' } ) ;
105+ mock . onGet ( '/foo' )
106106 . reply ( function ( ) {
107107 return instance . get ( '/bar' ) ;
108108 } ) ;
@@ -216,6 +216,18 @@ describe('MockAdapter basics', function() {
216216 } ) ;
217217 } ) ;
218218
219+ it ( 'allow removing mock handler' , function ( ) {
220+ const handler = mock . onGet ( '/' ) . reply ( 200 ) ;
221+ return instance . get ( '/' ) . then ( function ( response ) {
222+ expect ( response . status ) . to . equal ( 200 ) ;
223+ mock . removeHandler ( handler ) ;
224+ return instance . get ( '/' ) ;
225+ } ) . catch ( function ( error ) {
226+ expect ( error . response . status ) . to . equal ( 404 ) ;
227+ expect ( handler . called ) . to . equal ( 1 ) ;
228+ } ) ;
229+ } ) ;
230+
219231 it ( 'matches when parameters were not expected' , function ( ) {
220232 mock . onGet ( '/withParams' ) . reply ( 200 ) ;
221233 return instance
@@ -466,10 +478,10 @@ describe('MockAdapter basics', function() {
466478 it ( 'can chain calls to add mock handlers' , function ( ) {
467479 mock
468480 . onGet ( '/foo' )
469- . reply ( 200 )
470- . onAny ( '/bar' )
471- . reply ( 404 )
472- . onPost ( '/baz' )
481+ . reply ( 200 ) ;
482+ mock . onAny ( '/bar' )
483+ . reply ( 404 ) ;
484+ mock . onPost ( '/baz' )
473485 . reply ( 500 ) ;
474486
475487 expect ( mock . handlers [ 'get' ] . length ) . to . equal ( 2 ) ;
@@ -510,10 +522,9 @@ describe('MockAdapter basics', function() {
510522 } ) ;
511523
512524 it ( 'maps empty GET path to any path' , function ( ) {
513- mock
514- . onGet ( '/foo' )
515- . reply ( 200 , 'foo' )
516- . onGet ( )
525+ mock . onGet ( '/foo' )
526+ . reply ( 200 , 'foo' ) ;
527+ mock . onGet ( )
517528 . reply ( 200 , 'bar' ) ;
518529
519530 return Promise . all ( [
@@ -636,14 +647,13 @@ describe('MockAdapter basics', function() {
636647 } ) ;
637648
638649 it ( 'supports chaining on same path with different params' , function ( ) {
639- mock
640- . onGet ( '/users' , { params : { searchText : 'John' } } )
641- . reply ( 200 , { id : 1 } )
642- . onGet ( '/users' , { params : { searchText : 'James' } } )
643- . reply ( 200 , { id : 2 } )
644- . onGet ( '/users' , { params : { searchText : 'Jake' } } )
645- . reply ( 200 , { id : 3 } )
646- . onGet ( '/users' , { params : { searchText : 'Jackie' } } )
650+ mock . onGet ( '/users' , { params : { searchText : 'John' } } )
651+ . reply ( 200 , { id : 1 } ) ;
652+ mock . onGet ( '/users' , { params : { searchText : 'James' } } )
653+ . reply ( 200 , { id : 2 } ) ;
654+ mock . onGet ( '/users' , { params : { searchText : 'Jake' } } )
655+ . reply ( 200 , { id : 3 } ) ;
656+ mock . onGet ( '/users' , { params : { searchText : 'Jackie' } } )
647657 . reply ( 200 , { id : 4 } ) ;
648658
649659 return instance
@@ -739,10 +749,9 @@ describe('MockAdapter basics', function() {
739749 } ) ;
740750
741751 it ( 'allows overwriting mocks with parameters' , function ( ) {
742- mock
743- . onGet ( '/users' , { params : { searchText : 'John' } } )
744- . reply ( 500 )
745- . onGet ( '/users' , { params : { searchText : 'John' } } )
752+ mock . onGet ( '/users' , { params : { searchText : 'John' } } )
753+ . reply ( 500 ) ;
754+ mock . onGet ( '/users' , { params : { searchText : 'John' } } )
746755 . reply ( 200 , { id : 1 } ) ;
747756
748757 return instance
0 commit comments