MCPcopy Create free account
hub / github.com/angular/angular / mockFlush

Method mockFlush

packages/common/http/test/fetch_spec.ts:794–820  ·  view source on GitHub ↗
(
    status: number,
    statusText: string,
    body?: string | Blob | Uint8Array,
    headers?: Record<string, string>,
  )

Source from the content-addressed store, hash-verified

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);

Callers 3

xhr_spec.tsFile · 0.45
callFetchAndFlushFunction · 0.45
fetch_spec.tsFile · 0.45

Calls 3

setupBodyStreamMethod · 0.80
setBodyMethod · 0.80
resolveMethod · 0.65

Tested by

no test coverage detected