File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -1120,4 +1120,27 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w==
1120
1120
expect ( mock . done ( ) ) . toBe ( true ) ;
1121
1121
} ) ;
1122
1122
} ) ;
1123
+
1124
+ it ( "should not error for empty response body and json media type (#649)" , ( ) => {
1125
+ const mock = fetchMock . sandbox ( ) . get ( "path:/" , {
1126
+ status : 200 ,
1127
+ body : "" ,
1128
+ headers : {
1129
+ "content-length" : "0" ,
1130
+ "content-type" : "application/json; charset=utf-8" ,
1131
+ } ,
1132
+ } ) ;
1133
+
1134
+ expect ( request ) . not . toThrow ( ) ;
1135
+ return request ( "GET /" , {
1136
+ headers : {
1137
+ accept : "application/json" ,
1138
+ } ,
1139
+ request : {
1140
+ fetch : mock ,
1141
+ } ,
1142
+ } ) . then ( ( response ) => {
1143
+ expect ( response . data ) . toEqual ( "" ) ;
1144
+ } ) ;
1145
+ } ) ;
1123
1146
} ) ;
You can’t perform that action at this time.
0 commit comments