@@ -24,10 +24,14 @@ describe('fetch', () => {
24
24
25
25
const expectedHeaders = {
26
26
authorization : 'Bearer token' ,
27
- 'content-type' : 'application/json' ,
28
27
accept : 'application/json' ,
29
28
}
30
29
30
+ const headersWithContentType = {
31
+ ...expectedHeaders ,
32
+ 'content-type' : 'application/json' ,
33
+ }
34
+
31
35
it ( 'GET /query/{a}/{b}' , async ( ) => {
32
36
const fun = fetcher . path ( '/query/{a}/{b}' ) . method ( 'get' ) . create ( )
33
37
@@ -60,7 +64,7 @@ describe('fetch', () => {
60
64
expect ( data . params ) . toEqual ( { id : '1' } )
61
65
expect ( data . body ) . toEqual ( { list : [ 'b' , 'c' ] } )
62
66
expect ( data . query ) . toEqual ( { } )
63
- expect ( data . headers ) . toEqual ( expectedHeaders )
67
+ expect ( data . headers ) . toEqual ( headersWithContentType )
64
68
} )
65
69
} )
66
70
@@ -73,7 +77,7 @@ describe('fetch', () => {
73
77
expect ( data . params ) . toEqual ( { id : '1' } )
74
78
expect ( data . body ) . toEqual ( [ 'b' , 'c' ] )
75
79
expect ( data . query ) . toEqual ( { } )
76
- expect ( data . headers ) . toEqual ( expectedHeaders )
80
+ expect ( data . headers ) . toEqual ( headersWithContentType )
77
81
} )
78
82
} )
79
83
@@ -93,10 +97,20 @@ describe('fetch', () => {
93
97
expect ( data . params ) . toEqual ( { id : '1' } )
94
98
expect ( data . body ) . toEqual ( { list : [ 'b' , 'c' ] } )
95
99
expect ( data . query ) . toEqual ( { scalar : 'a' } )
96
- expect ( data . headers ) . toEqual ( expectedHeaders )
100
+ expect ( data . headers ) . toEqual ( headersWithContentType )
97
101
} )
98
102
} )
99
103
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
+
100
114
it ( 'GET /error' , async ( ) => {
101
115
expect . assertions ( 3 )
102
116
0 commit comments