fix(common): don't convert null to a string when flushing a mock request (#21417)
A bug in TestRequest caused null response bodies to be stringified. This change causes null to be treated faithfully. Fixes #20744 PR Close #21417
This commit is contained in:
@ -184,26 +184,17 @@ function _maybeConvertBody(
|
||||
responseType: string, body: ArrayBuffer | Blob | string | number | Object |
|
||||
(string | number | Object | null)[] | null): ArrayBuffer|Blob|string|number|Object|
|
||||
(string | number | Object | null)[]|null {
|
||||
if (body === null) {
|
||||
return null;
|
||||
}
|
||||
switch (responseType) {
|
||||
case 'arraybuffer':
|
||||
if (body === null) {
|
||||
return null;
|
||||
}
|
||||
return _toArrayBufferBody(body);
|
||||
case 'blob':
|
||||
if (body === null) {
|
||||
return null;
|
||||
}
|
||||
return _toBlob(body);
|
||||
case 'json':
|
||||
if (body === null) {
|
||||
return 'null';
|
||||
}
|
||||
return _toJsonBody(body);
|
||||
case 'text':
|
||||
if (body === null) {
|
||||
return null;
|
||||
}
|
||||
return _toTextBody(body);
|
||||
default:
|
||||
throw new Error(`Unsupported responseType: ${responseType}`);
|
||||
|
Reference in New Issue
Block a user