(
status: number,
statusText: string,
body?: string | Blob | Uint8Array,
headers?: Record<string, string>,
)
| 969 | }; |
| 970 | |
| 971 | mockFlush( |
| 972 | status: number, |
| 973 | statusText: string, |
| 974 | body?: string | Blob | Uint8Array, |
| 975 | headers?: Record<string, string>, |
| 976 | ): void { |
| 977 | this.clearWarningTimeout?.(); |
| 978 | if (typeof body === 'string') { |
| 979 | this.response.setupBodyStream(body); |
| 980 | } else { |
| 981 | this.response.setBody(body); |
| 982 | } |
| 983 | const response = new Response(this.response.stream, { |
| 984 | statusText, |
| 985 | headers: {...this.response.headers, ...(headers ?? {})}, |
| 986 | }); |
| 987 | |
| 988 | // Have to be set outside the constructor because it might throw |
| 989 | // RangeError: init["status"] must be in the range of 200 to 599, inclusive |
| 990 | Object.defineProperty(response, 'status', {value: status}); |
| 991 | |
| 992 | if (this.response.url) { |
| 993 | // url is readonly |
| 994 | Object.defineProperty(response, 'url', {value: this.response.url}); |
| 995 | } |
| 996 | this.resolve(response); |
| 997 | } |
| 998 | |
| 999 | mockProgressEvent(loaded: number): void { |
| 1000 | this.response.progress.push(loaded); |
no test coverage detected