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

Method mockFlush

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

Source from the content-addressed store, hash-verified

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

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