This repository was archived by the owner on Aug 3, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -212,6 +212,40 @@ describe('successful requests', () => {
212212 } , networkTimeout ) ;
213213 } ) ;
214214
215+ test ( 'it sets data to `null` if the contentType does not parse the data' , done => {
216+ fetchMock . get (
217+ '/test/succeeds/second-mismatch-content-type' ,
218+ new Promise ( resolve => {
219+ resolve ( successfulResponse ( ) ) ;
220+ } )
221+ ) ;
222+
223+ expect . assertions ( 2 ) ;
224+ const afterFetchMock = jest . fn ( ) ;
225+
226+ mount (
227+ < Fetch
228+ url = "/test/succeeds/second-mismatch-content-type"
229+ afterFetch = { afterFetchMock }
230+ responseType = "json"
231+ />
232+ ) ;
233+
234+ setTimeout ( ( ) => {
235+ expect ( afterFetchMock ) . toHaveBeenCalledTimes ( 1 ) ;
236+ expect ( afterFetchMock ) . toBeCalledWith (
237+ expect . objectContaining ( {
238+ url : '/test/succeeds/second-mismatch-content-type' ,
239+ error : null ,
240+ failed : false ,
241+ didUnmount : false ,
242+ data : null
243+ } )
244+ ) ;
245+ done ( ) ;
246+ } , networkTimeout ) ;
247+ } ) ;
248+
215249 test ( 'it accepts a custom `responseType` as a function, and calls afterFetch with the right arguments' , done => {
216250 fetchMock . get (
217251 '/test/succeeds/secondpls' ,
You can’t perform that action at this time.
0 commit comments