Project

General

Profile

1
/**
2
 * @license
3
 * Copyright Google Inc. All Rights Reserved.
4
 *
5
 * Use of this source code is governed by an MIT-style license that can be
6
 * found in the LICENSE file at https://angular.io/license
7
 */
8
import { HttpBackend, HttpEvent, HttpRequest } from '@angular/common/http';
9
import { Observable } from 'rxjs/Observable';
10
import { HttpTestingController, RequestMatch } from './api';
11
import { TestRequest } from './request';
12
/**
13
 * A testing backend for `HttpClient` which both acts as an `HttpBackend`
14
 * and as the `HttpTestingController`.
15
 *
16
 * `HttpClientTestingBackend` works by keeping a list of all open requests.
17
 * As requests come in, they're added to the list. Users can assert that specific
18
 * requests were made and then flush them. In the end, a verify() method asserts
19
 * that no unexpected requests were made.
20
 *
21
 * @experimental
22
 */
23
export declare class HttpClientTestingBackend implements HttpBackend, HttpTestingController {
24
    /**
25
     * List of pending requests which have not yet been expected.
26
     */
27
    private open;
28
    /**
29
     * Handle an incoming request by queueing it in the list of open requests.
30
     */
31
    handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
32
    /**
33
     * Helper function to search for requests in the list of open requests.
34
     */
35
    private _match(match);
36
    /**
37
     * Search for requests in the list of open requests, and return all that match
38
     * without asserting anything about the number of matches.
39
     */
40
    match(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean)): TestRequest[];
41
    /**
42
     * Expect that a single outstanding request matches the given matcher, and return
43
     * it.
44
     *
45
     * Requests returned through this API will no longer be in the list of open requests,
46
     * and thus will not match twice.
47
     */
48
    expectOne(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean), description?: string): TestRequest;
49
    /**
50
     * Expect that no outstanding requests match the given matcher, and throw an error
51
     * if any do.
52
     */
53
    expectNone(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean), description?: string): void;
54
    /**
55
     * Validate that there are no outstanding requests.
56
     */
57
    verify(opts?: {
58
        ignoreCancelled?: boolean;
59
    }): void;
60
    private descriptionFromMatcher(matcher);
61
}
(2-2/4)