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