@@ -725,6 +725,56 @@ describe('TryIt', () => {
725
725
} ) ;
726
726
} ) ;
727
727
728
+ describe ( 'No Request body' , ( ) => {
729
+ it ( 'with GET method' , async ( ) => {
730
+ render ( < TryItWithPersistence httpOperation = { basicOperation } /> ) ;
731
+
732
+ clickSend ( ) ;
733
+
734
+ await waitFor ( ( ) => expect ( fetchMock ) . toHaveBeenCalled ( ) ) ;
735
+ const requestInit = fetchMock . mock . calls [ 0 ] [ 1 ] ! ;
736
+ expect ( requestInit . method ) . toMatch ( / ^ g e t $ / i) ;
737
+ const headers = new Headers ( requestInit . headers ) ;
738
+ expect ( headers . get ( 'Content-Type' ) ) . toBe ( null ) ;
739
+ } ) ;
740
+
741
+ it ( 'with POST method' , async ( ) => {
742
+ render ( < TryItWithPersistence httpOperation = { { ...basicOperation , request : undefined , method : 'POST' } } /> ) ;
743
+
744
+ clickSend ( ) ;
745
+
746
+ await waitFor ( ( ) => expect ( fetchMock ) . toHaveBeenCalled ( ) ) ;
747
+ const requestInit = fetchMock . mock . calls [ 0 ] [ 1 ] ! ;
748
+ expect ( requestInit . method ) . toMatch ( / ^ p o s t $ / i) ;
749
+ const headers = new Headers ( requestInit . headers ) ;
750
+ expect ( headers . get ( 'Content-Type' ) ) . toBe ( null ) ;
751
+ } ) ;
752
+
753
+ it ( 'with PATCH method' , async ( ) => {
754
+ render ( < TryItWithPersistence httpOperation = { { ...basicOperation , request : undefined , method : 'PATCH' } } /> ) ;
755
+
756
+ clickSend ( ) ;
757
+
758
+ await waitFor ( ( ) => expect ( fetchMock ) . toHaveBeenCalled ( ) ) ;
759
+ const requestInit = fetchMock . mock . calls [ 0 ] [ 1 ] ! ;
760
+ expect ( requestInit . method ) . toMatch ( / ^ p a t c h $ / i) ;
761
+ const headers = new Headers ( requestInit . headers ) ;
762
+ expect ( headers . get ( 'Content-Type' ) ) . toBe ( null ) ;
763
+ } ) ;
764
+
765
+ it ( 'with PUT method' , async ( ) => {
766
+ render ( < TryItWithPersistence httpOperation = { { ...basicOperation , request : undefined , method : 'PUT' } } /> ) ;
767
+
768
+ clickSend ( ) ;
769
+
770
+ await waitFor ( ( ) => expect ( fetchMock ) . toHaveBeenCalled ( ) ) ;
771
+ const requestInit = fetchMock . mock . calls [ 0 ] [ 1 ] ! ;
772
+ expect ( requestInit . method ) . toMatch ( / ^ p u t $ / i) ;
773
+ const headers = new Headers ( requestInit . headers ) ;
774
+ expect ( headers . get ( 'Content-Type' ) ) . toBe ( null ) ;
775
+ } ) ;
776
+ } ) ;
777
+
728
778
describe ( 'Mocking' , ( ) => {
729
779
it ( 'Shows mock button' , ( ) => {
730
780
render ( < TryItWithPersistence httpOperation = { basicOperation } mockUrl = "https://mock-todos.stoplight.io" /> ) ;
0 commit comments