(
status: number,
statusText: string,
body?: string | Blob | Uint8Array,
headers?: Record<string, string>,
)
| 802 | }; |
| 803 | |
| 804 | mockFlush( |
| 805 | status: number, |
| 806 | statusText: string, |
| 807 | body?: string | Blob | Uint8Array, |
| 808 | headers?: Record<string, string>, |
| 809 | ): void { |
| 810 | this.clearWarningTimeout?.(); |
| 811 | if (typeof body === 'string') { |
| 812 | this.response.setupBodyStream(body); |
| 813 | } else { |
| 814 | this.response.setBody(body); |
| 815 | } |
| 816 | const response = new Response(this.response.stream, { |
| 817 | statusText, |
| 818 | headers: {...this.response.headers, ...(headers ?? {})}, |
| 819 | }); |
| 820 | |
| 821 | // Have to be set outside the constructor because it might throw |
| 822 | // RangeError: init["status"] must be in the range of 200 to 599, inclusive |
| 823 | Object.defineProperty(response, 'status', {value: status}); |
| 824 | |
| 825 | if (this.response.url) { |
| 826 | // url is readonly |
| 827 | Object.defineProperty(response, 'url', {value: this.response.url}); |
| 828 | } |
| 829 | this.resolve(response); |
| 830 | } |
| 831 | |
| 832 | mockProgressEvent(loaded: number): void { |
| 833 | this.response.progress.push(loaded); |
no test coverage detected