@@ -98,75 +98,70 @@ describe("createClient options", () => {
9898 BODIES . map ( ( body ) => [ method , body ] as const ) ,
9999 ) ;
100100
101- test . each ( METHOD_BODY_COMBINATIONS ) (
102- "implicit default content-type for body-full requests - %s, %j" ,
103- async ( method , body ) => {
104- const contentType = await fireRequestAndGetContentType ( {
105- method,
106- fetchOptions : { body } ,
107- } ) ;
108-
109- expect ( contentType ) . toBe ( "application/json" ) ;
110- } ,
111- ) ;
101+ test . each (
102+ METHOD_BODY_COMBINATIONS ,
103+ ) ( "implicit default content-type for body-full requests - %s, %j" , async ( method , body ) => {
104+ const contentType = await fireRequestAndGetContentType ( {
105+ method,
106+ fetchOptions : { body } ,
107+ } ) ;
112108
113- test . each ( METHOD_BODY_COMBINATIONS ) (
114- "provided default content-type for body-full requests - %s, %j" ,
115- async ( method , body ) => {
116- const contentType = await fireRequestAndGetContentType ( {
117- defaultHeaders : { "content-type" : "application/my-json" } ,
118- method,
119- fetchOptions : { body } ,
120- } ) ;
121-
122- expect ( contentType ) . toBe ( "application/my-json" ) ;
123- } ,
124- ) ;
109+ expect ( contentType ) . toBe ( "application/json" ) ;
110+ } ) ;
125111
126- test . each ( METHOD_BODY_COMBINATIONS ) (
127- "native-fetch default content-type for body-full requests, when default is suppressed - %s, %j" ,
128- async ( method , body ) => {
129- const contentType = await fireRequestAndGetContentType ( {
130- defaultHeaders : { "content-type" : null } ,
131- method,
132- fetchOptions : { body } ,
133- } ) ;
134- // the fetch implementation won't allow sending a body without content-type,
135- // and it defaults to `text/plain;charset=UTF-8`, however the actual default value
136- // is irrelevant and might be flaky across different fetch implementations
137- // for us, it's important that it's not `application/json`
138- expect ( contentType ) . not . toBe ( "application/json" ) ;
139- } ,
140- ) ;
112+ test . each (
113+ METHOD_BODY_COMBINATIONS ,
114+ ) ( "provided default content-type for body-full requests - %s, %j" , async ( method , body ) => {
115+ const contentType = await fireRequestAndGetContentType ( {
116+ defaultHeaders : { "content-type" : "application/my-json" } ,
117+ method,
118+ fetchOptions : { body } ,
119+ } ) ;
141120
142- test . each ( METHOD_BODY_COMBINATIONS ) (
143- "specified content-type for body-full requests - %s, %j" ,
144- async ( method , body ) => {
145- const contentType = await fireRequestAndGetContentType ( {
146- method,
147- fetchOptions : {
148- body,
149- headers : { "content-type" : "application/my-json" } ,
150- } ,
151- } ) ;
152-
153- expect ( contentType ) . toBe ( "application/my-json" ) ;
154- } ,
155- ) ;
121+ expect ( contentType ) . toBe ( "application/my-json" ) ;
122+ } ) ;
156123
157- test . each ( METHOD_BODY_COMBINATIONS ) (
158- "specified content-type for body-full requests, even when default is suppressed - %s, %j" ,
159- async ( method , body ) => {
160- const contentType = await fireRequestAndGetContentType ( {
161- method,
162- fetchOptions : {
163- body,
164- headers : { "content-type" : "application/my-json" } ,
165- } ,
166- } ) ;
167-
168- expect ( contentType ) . toBe ( "application/my-json" ) ;
169- } ,
170- ) ;
124+ test . each (
125+ METHOD_BODY_COMBINATIONS ,
126+ ) ( "native-fetch default content-type for body-full requests, when default is suppressed - %s, %j" , async ( method , body ) => {
127+ const contentType = await fireRequestAndGetContentType ( {
128+ defaultHeaders : { "content-type" : null } ,
129+ method,
130+ fetchOptions : { body } ,
131+ } ) ;
132+ // the fetch implementation won't allow sending a body without content-type,
133+ // and it defaults to `text/plain;charset=UTF-8`, however the actual default value
134+ // is irrelevant and might be flaky across different fetch implementations
135+ // for us, it's important that it's not `application/json`
136+ expect ( contentType ) . not . toBe ( "application/json" ) ;
137+ } ) ;
138+
139+ test . each (
140+ METHOD_BODY_COMBINATIONS ,
141+ ) ( "specified content-type for body-full requests - %s, %j" , async ( method , body ) => {
142+ const contentType = await fireRequestAndGetContentType ( {
143+ method,
144+ fetchOptions : {
145+ body,
146+ headers : { "content-type" : "application/my-json" } ,
147+ } ,
148+ } ) ;
149+
150+ expect ( contentType ) . toBe ( "application/my-json" ) ;
151+ } ) ;
152+
153+ test . each (
154+ METHOD_BODY_COMBINATIONS ,
155+ ) ( "specified content-type for body-full requests, even when default is suppressed - %s, %j" , async ( method , body ) => {
156+ const contentType = await fireRequestAndGetContentType ( {
157+ method,
158+ fetchOptions : {
159+ body,
160+ headers : { "content-type" : "application/my-json" } ,
161+ } ,
162+ } ) ;
163+
164+ expect ( contentType ) . toBe ( "application/my-json" ) ;
165+ } ) ;
171166 } ) ;
172167} ) ;
0 commit comments