File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 116116 }
117117 }
118118
119+ if ( cleaned . body ) {
120+ headers [ 'Content-Length' ] = cleaned . body . length ;
121+ }
122+
119123 __doRequest (
120124 method ,
121125 cleaned . url ,
Original file line number Diff line number Diff line change @@ -211,6 +211,13 @@ fragment auth_error on Error {messages}`;
211211 expect ( xhr . open ) . toHaveBeenCalledWith ( method , expect . stringMatching ( url ) , true )
212212 expect ( xhr . open ) . toHaveBeenCalledWith ( method , expect . stringMatching ( / \? q u e r y = .+ & v a r i a b l e s = / ) , true )
213213 } ) ;
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+ } ) ;
214221 } ) ;
215222
216223 describe ( 'when executing the queries normally' , ( ) => {
@@ -221,6 +228,13 @@ fragment auth_error on Error {messages}`;
221228 expect ( xhr . send ) . toHaveBeenCalled ( ) ;
222229 } ) ;
223230
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+
224238 it ( 'resolves the response in the promise' , ( ) => {
225239 let data = { post : { id : 123 , title : 'title' , text : 'text' } } ;
226240 mockXHR ( 200 , data ) ;
You can’t perform that action at this time.
0 commit comments