1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import { HttpBackend } from '@angular/common/http';
|
8 | import { HttpEvent } from '@angular/common/http';
|
9 | import { HttpHeaders } from '@angular/common/http';
|
10 | import { HttpRequest } from '@angular/common/http';
|
11 | import { Observable } from 'rxjs';
|
12 | import { Observer } from 'rxjs';
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | export declare class HttpClientTestingModule {
|
23 | }
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | export declare abstract class HttpTestingController {
|
32 | |
33 |
|
34 |
|
35 | abstract match(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean)): TestRequest[];
|
36 | /**
|
37 | * Expect that a single request has been made which matches the given URL, and return its
|
38 | * mock.
|
39 | *
|
40 | * If no such request has been made, or more than one such request has been made, fail with an
|
41 | * error message including the given request description, if any.
|
42 | */
|
43 | abstract expectOne(url: string, description?: string): TestRequest;
|
44 | /**
|
45 | * Expect that a single request has been made which matches the given parameters, and return
|
46 | * its mock.
|
47 | *
|
48 | * If no such request has been made, or more than one such request has been made, fail with an
|
49 | * error message including the given request description, if any.
|
50 | */
|
51 | abstract expectOne(params: RequestMatch, description?: string): TestRequest;
|
52 | /**
|
53 | * Expect that a single request has been made which matches the given predicate function, and
|
54 | * return its mock.
|
55 | *
|
56 | * If no such request has been made, or more than one such request has been made, fail with an
|
57 | * error message including the given request description, if any.
|
58 | */
|
59 | abstract expectOne(matchFn: ((req: HttpRequest<any>) => boolean), description?: string): TestRequest;
|
60 | /**
|
61 | * Expect that a single request has been made which matches the given condition, and return
|
62 | * its mock.
|
63 | *
|
64 | * If no such request has been made, or more than one such request has been made, fail with an
|
65 | * error message including the given request description, if any.
|
66 | */
|
67 | abstract expectOne(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean), description?: string): TestRequest;
|
68 | /**
|
69 | * Expect that no requests have been made which match the given URL.
|
70 | *
|
71 | * If a matching request has been made, fail with an error message including the given request
|
72 | * description, if any.
|
73 | */
|
74 | abstract expectNone(url: string, description?: string): void;
|
75 | /**
|
76 | * Expect that no requests have been made which match the given parameters.
|
77 | *
|
78 | * If a matching request has been made, fail with an error message including the given request
|
79 | * description, if any.
|
80 | */
|
81 | abstract expectNone(params: RequestMatch, description?: string): void;
|
82 | /**
|
83 | * Expect that no requests have been made which match the given predicate function.
|
84 | *
|
85 | * If a matching request has been made, fail with an error message including the given request
|
86 | * description, if any.
|
87 | */
|
88 | abstract expectNone(matchFn: ((req: HttpRequest<any>) => boolean), description?: string): void;
|
89 | /**
|
90 | * Expect that no requests have been made which match the given condition.
|
91 | *
|
92 | * If a matching request has been made, fail with an error message including the given request
|
93 | * description, if any.
|
94 | */
|
95 | abstract expectNone(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean), description?: string): void;
|
96 | /**
|
97 | * Verify that no unmatched requests are outstanding.
|
98 | *
|
99 | * If any requests are outstanding, fail with an error message indicating which requests were not
|
100 | * handled.
|
101 | *
|
102 | * If `ignoreCancelled` is not set (the default), `verify()` will also fail if cancelled requests
|
103 | * were not explicitly matched.
|
104 | */
|
105 | abstract verify(opts?: {
|
106 | ignoreCancelled?: boolean;
|
107 | }): void;
|
108 | }
|
109 |
|
110 | /**
|
111 | * Defines a matcher for requests based on URL, method, or both.
|
112 | *
|
113 | * @publicApi
|
114 | */
|
115 | export declare interface RequestMatch {
|
116 | method?: string;
|
117 | url?: string;
|
118 | }
|
119 |
|
120 | /**
|
121 | * A mock requests that was received and is ready to be answered.
|
122 | *
|
123 | * This interface allows access to the underlying `HttpRequest`, and allows
|
124 | * responding with `HttpEvent`s or `HttpErrorResponse`s.
|
125 | *
|
126 | * @publicApi
|
127 | */
|
128 | export declare class TestRequest {
|
129 | request: HttpRequest<any>;
|
130 | private observer;
|
131 | /**
|
132 | * Whether the request was cancelled after it was sent.
|
133 | */
|
134 | readonly cancelled: boolean;
|
135 | constructor(request: HttpRequest<any>, observer: Observer<HttpEvent<any>>);
|
136 | /**
|
137 | * Resolve the request by returning a body plus additional HTTP information (such as response
|
138 | * headers) if provided.
|
139 | * If the request specifies an expected body type, the body is converted into the requested type.
|
140 | * Otherwise, the body is converted to `JSON` by default.
|
141 | *
|
142 | * Both successful and unsuccessful responses can be delivered via `flush()`.
|
143 | */
|
144 | flush(body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[] | null, opts?: {
|
145 | headers?: HttpHeaders | {
|
146 | [name: string]: string | string[];
|
147 | };
|
148 | status?: number;
|
149 | statusText?: string;
|
150 | }): void;
|
151 | /**
|
152 | * Resolve the request by returning an `ErrorEvent` (e.g. simulating a network failure).
|
153 | */
|
154 | error(error: ErrorEvent, opts?: {
|
155 | headers?: HttpHeaders | {
|
156 | [name: string]: string | string[];
|
157 | };
|
158 | status?: number;
|
159 | statusText?: string;
|
160 | }): void;
|
161 | /**
|
162 | * Deliver an arbitrary `HttpEvent` (such as a progress event) on the response stream for this
|
163 | * request.
|
164 | */
|
165 | event(event: HttpEvent<any>): void;
|
166 | }
|
167 |
|
168 | /**
|
169 | * A testing backend for `HttpClient` which both acts as an `HttpBackend`
|
170 | * and as the `HttpTestingController`.
|
171 | *
|
172 | * `HttpClientTestingBackend` works by keeping a list of all open requests.
|
173 | * As requests come in, they're added to the list. Users can assert that specific
|
174 | * requests were made and then flush them. In the end, a verify() method asserts
|
175 | * that no unexpected requests were made.
|
176 | *
|
177 | *
|
178 | */
|
179 | export declare class ɵangular_packages_common_http_testing_testing_a implements HttpBackend, HttpTestingController {
|
180 | /**
|
181 | * List of pending requests which have not yet been expected.
|
182 | */
|
183 | private open;
|
184 | /**
|
185 | * Handle an incoming request by queueing it in the list of open requests.
|
186 | */
|
187 | handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
|
188 | /**
|
189 | * Helper function to search for requests in the list of open requests.
|
190 | */
|
191 | private _match;
|
192 | /**
|
193 | * Search for requests in the list of open requests, and return all that match
|
194 | * without asserting anything about the number of matches.
|
195 | */
|
196 | match(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean)): TestRequest[];
|
197 | /**
|
198 | * Expect that a single outstanding request matches the given matcher, and return
|
199 | * it.
|
200 | *
|
201 | * Requests returned through this API will no longer be in the list of open requests,
|
202 | * and thus will not match twice.
|
203 | */
|
204 | expectOne(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean), description?: string): TestRequest;
|
205 | /**
|
206 | * Expect that no outstanding requests match the given matcher, and throw an error
|
207 | * if any do.
|
208 | */
|
209 | expectNone(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean), description?: string): void;
|
210 | /**
|
211 | * Validate that there are no outstanding requests.
|
212 | */
|
213 | verify(opts?: {
|
214 | ignoreCancelled?: boolean;
|
215 | }): void;
|
216 | private descriptionFromMatcher;
|
217 | }
|
218 |
|
219 | export { }
|
220 |
|
\ | No newline at end of file |