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