MCPcopy Index your code
hub / github.com/angular/angular / mockFlush

Method mockFlush

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

Source from the content-addressed store, hash-verified

721 };
722
723 mockFlush(
724 status: number,
725 statusText: string,
726 body?: string | Blob,
727 headers?: Record<string, string>,
728 ): void {
729 this.clearWarningTimeout?.();
730 if (typeof body === 'string') {
731 this.response.setupBodyStream(body);
732 } else {
733 this.response.setBody(body);
734 }
735 const response = new Response(this.response.stream, {
736 statusText,
737 headers: {...this.response.headers, ...(headers ?? {})},
738 });
739
740 // Have to be set outside the constructor because it might throw
741 // RangeError: init["status"] must be in the range of 200 to 599, inclusive
742 Object.defineProperty(response, 'status', {value: status});
743
744 if (this.response.url) {
745 // url is readonly
746 Object.defineProperty(response, 'url', {value: this.response.url});
747 }
748 this.resolve(response);
749 }
750
751 mockProgressEvent(loaded: number): void {
752 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