@@ -24,10 +24,14 @@ describe('fetch', () => {
2424
2525 const expectedHeaders = {
2626 authorization : 'Bearer token' ,
27- 'content-type' : 'application/json' ,
2827 accept : 'application/json' ,
2928 }
3029
30+ const headersWithContentType = {
31+ ...expectedHeaders ,
32+ 'content-type' : 'application/json' ,
33+ }
34+
3135 it ( 'GET /query/{a}/{b}' , async ( ) => {
3236 const fun = fetcher . path ( '/query/{a}/{b}' ) . method ( 'get' ) . create ( )
3337
@@ -60,7 +64,7 @@ describe('fetch', () => {
6064 expect ( data . params ) . toEqual ( { id : '1' } )
6165 expect ( data . body ) . toEqual ( { list : [ 'b' , 'c' ] } )
6266 expect ( data . query ) . toEqual ( { } )
63- expect ( data . headers ) . toEqual ( expectedHeaders )
67+ expect ( data . headers ) . toEqual ( headersWithContentType )
6468 } )
6569 } )
6670
@@ -73,7 +77,7 @@ describe('fetch', () => {
7377 expect ( data . params ) . toEqual ( { id : '1' } )
7478 expect ( data . body ) . toEqual ( [ 'b' , 'c' ] )
7579 expect ( data . query ) . toEqual ( { } )
76- expect ( data . headers ) . toEqual ( expectedHeaders )
80+ expect ( data . headers ) . toEqual ( headersWithContentType )
7781 } )
7882 } )
7983
@@ -93,10 +97,20 @@ describe('fetch', () => {
9397 expect ( data . params ) . toEqual ( { id : '1' } )
9498 expect ( data . body ) . toEqual ( { list : [ 'b' , 'c' ] } )
9599 expect ( data . query ) . toEqual ( { scalar : 'a' } )
96- expect ( data . headers ) . toEqual ( expectedHeaders )
100+ expect ( data . headers ) . toEqual ( headersWithContentType )
97101 } )
98102 } )
99103
104+ it ( `DELETE /body/{id} (empty body)` , async ( ) => {
105+ const fun = fetcher . path ( '/body/{id}' ) . method ( 'delete' ) . create ( )
106+
107+ const { data } = await fun ( { id : 1 } as any )
108+
109+ expect ( data . params ) . toEqual ( { id : '1' } )
110+ expect ( data . headers ) . toHaveProperty ( 'accept' )
111+ expect ( data . headers ) . not . toHaveProperty ( 'content-type' )
112+ } )
113+
100114 it ( 'GET /error' , async ( ) => {
101115 expect . assertions ( 3 )
102116
0 commit comments