@@ -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
@@ -510,10 +522,10 @@ describe('MockAdapter basics', function() {
510522 it ( 'can chain calls to add mock handlers' , function ( ) {
511523 mock
512524 . onGet ( '/foo' )
513- . reply ( 200 )
514- . onAny ( '/bar' )
515- . reply ( 404 )
516- . onPost ( '/baz' )
525+ . reply ( 200 ) ;
526+ mock . onAny ( '/bar' )
527+ . reply ( 404 ) ;
528+ mock . onPost ( '/baz' )
517529 . reply ( 500 ) ;
518530
519531 expect ( mock . handlers [ 'get' ] . length ) . to . equal ( 2 ) ;
@@ -554,10 +566,9 @@ describe('MockAdapter basics', function() {
554566 } ) ;
555567
556568 it ( 'maps empty GET path to any path' , function ( ) {
557- mock
558- . onGet ( '/foo' )
559- . reply ( 200 , 'foo' )
560- . onGet ( )
569+ mock . onGet ( '/foo' )
570+ . reply ( 200 , 'foo' ) ;
571+ mock . onGet ( )
561572 . reply ( 200 , 'bar' ) ;
562573
563574 return Promise . all ( [
@@ -680,14 +691,13 @@ describe('MockAdapter basics', function() {
680691 } ) ;
681692
682693 it ( 'supports chaining on same path with different params' , function ( ) {
683- mock
684- . onGet ( '/users' , { params : { searchText : 'John' } } )
685- . reply ( 200 , { id : 1 } )
686- . onGet ( '/users' , { params : { searchText : 'James' } } )
687- . reply ( 200 , { id : 2 } )
688- . onGet ( '/users' , { params : { searchText : 'Jake' } } )
689- . reply ( 200 , { id : 3 } )
690- . onGet ( '/users' , { params : { searchText : 'Jackie' } } )
694+ mock . onGet ( '/users' , { params : { searchText : 'John' } } )
695+ . reply ( 200 , { id : 1 } ) ;
696+ mock . onGet ( '/users' , { params : { searchText : 'James' } } )
697+ . reply ( 200 , { id : 2 } ) ;
698+ mock . onGet ( '/users' , { params : { searchText : 'Jake' } } )
699+ . reply ( 200 , { id : 3 } ) ;
700+ mock . onGet ( '/users' , { params : { searchText : 'Jackie' } } )
691701 . reply ( 200 , { id : 4 } ) ;
692702
693703 return instance
@@ -783,10 +793,9 @@ describe('MockAdapter basics', function() {
783793 } ) ;
784794
785795 it ( 'allows overwriting mocks with parameters' , function ( ) {
786- mock
787- . onGet ( '/users' , { params : { searchText : 'John' } } )
788- . reply ( 500 )
789- . onGet ( '/users' , { params : { searchText : 'John' } } )
796+ mock . onGet ( '/users' , { params : { searchText : 'John' } } )
797+ . reply ( 500 ) ;
798+ mock . onGet ( '/users' , { params : { searchText : 'John' } } )
790799 . reply ( 200 , { id : 1 } ) ;
791800
792801 return instance
0 commit comments