TestRequest
class
A mock requests that was received and is ready to be answered.
class TestRequest {
constructor(request: HttpRequest<any>, observer: Observer<HttpEvent<any>>)
cancelled: boolean
request: HttpRequest<any>
flush(body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[] | null, opts: {...}): void
error(error: ErrorEvent, opts: {...}): void
event(event: HttpEvent<any>): void
} Description
This interface allows access to the underlying HttpRequest, and allows responding with HttpEvents or HttpErrorResponses.
Constructor
|
| request | Type: |
| observer | Type: |
Properties
| Property | Description |
|---|---|
cancelled: boolean |
Read-only. Whether the request was cancelled after it was sent. |
request: HttpRequest<any> | Declared in constructor. |
Methods
| flush() | ||||
|---|---|---|---|---|
| Resolve the request by returning a body plus additional HTTP information (such as response headers) if provided. | ||||
|
| body | Type: |
| opts | Type: Optional. Default is |
Returns
void
Both successful and unsuccessful responses can be delivered via flush().
| error() | ||||
|---|---|---|---|---|
| Resolve the request by returning an | ||||
|
| error | Type: |
| opts | Type: Optional. Default is |
Returns
void
| event() | ||
|---|---|---|
| Deliver an arbitrary | ||
|
| event | Type: |
Returns
void
© 2010–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v6.angular.io/api/common/http/testing/TestRequest