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