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

Method mockFlush

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

Source from the content-addressed store, hash-verified

969 };
970
971 mockFlush(
972 status: number,
973 statusText: string,
974 body?: string | Blob | Uint8Array,
975 headers?: Record<string, string>,
976 ): void {
977 this.clearWarningTimeout?.();
978 if (typeof body === 'string') {
979 this.response.setupBodyStream(body);
980 } else {
981 this.response.setBody(body);
982 }
983 const response = new Response(this.response.stream, {
984 statusText,
985 headers: {...this.response.headers, ...(headers ?? {})},
986 });
987
988 // Have to be set outside the constructor because it might throw
989 // RangeError: init["status"] must be in the range of 200 to 599, inclusive
990 Object.defineProperty(response, 'status', {value: status});
991
992 if (this.response.url) {
993 // url is readonly
994 Object.defineProperty(response, 'url', {value: this.response.url});
995 }
996 this.resolve(response);
997 }
998
999 mockProgressEvent(loaded: number): void {
1000 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