File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 116
116
}
117
117
}
118
118
119
+ if ( cleaned . body ) {
120
+ headers [ 'Content-Length' ] = cleaned . body . length ;
121
+ }
122
+
119
123
__doRequest (
120
124
method ,
121
125
cleaned . url ,
Original file line number Diff line number Diff line change @@ -211,6 +211,13 @@ fragment auth_error on Error {messages}`;
211
211
expect ( xhr . open ) . toHaveBeenCalledWith ( method , expect . stringMatching ( url ) , true )
212
212
expect ( xhr . open ) . toHaveBeenCalledWith ( method , expect . stringMatching ( / \? q u e r y = .+ & v a r i a b l e s = / ) , true )
213
213
} ) ;
214
+
215
+ it ( 'does not send the content-length header' , ( ) => {
216
+ let xhr = mockXHR ( 200 , { } ) ;
217
+ xhr . send = jest . fn ( ) ;
218
+ fetchPost ( { id : 123 } ) ;
219
+ expect ( xhr . setRequestHeader ) . not . toHaveBeenCalledWith ( 'Content-Length' , expect . anything ) ;
220
+ } ) ;
214
221
} ) ;
215
222
216
223
describe ( 'when executing the queries normally' , ( ) => {
@@ -221,6 +228,13 @@ fragment auth_error on Error {messages}`;
221
228
expect ( xhr . send ) . toHaveBeenCalled ( ) ;
222
229
} ) ;
223
230
231
+ it ( 'sends the content-length header' , ( ) => {
232
+ let xhr = mockXHR ( 200 , { } ) ;
233
+ xhr . send = jest . fn ( ) ;
234
+ fetchPost ( { id : 123 } ) ;
235
+ expect ( xhr . setRequestHeader ) . toHaveBeenCalledWith ( 'Content-Length' , 99 ) ;
236
+ } ) ;
237
+
224
238
it ( 'resolves the response in the promise' , ( ) => {
225
239
let data = { post : { id : 123 , title : 'title' , text : 'text' } } ;
226
240
mockXHR ( 200 , data ) ;
You can’t perform that action at this time.
0 commit comments