@angular/compiler
Version:
Angular - the compiler library
45 lines (44 loc) • 1.73 kB
TypeScript
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { ResourceLoader } from '@angular/compiler';
/**
* A mock implementation of {@link ResourceLoader} that allows outgoing requests to be mocked
* and responded to within a single test, without going to the network.
*/
export declare class MockResourceLoader extends ResourceLoader {
private _expectations;
private _definitions;
private _requests;
get(url: string): Promise<string>;
hasPendingRequests(): boolean;
/**
* Add an expectation for the given URL. Incoming requests will be checked against
* the next expectation (in FIFO order). The `verifyNoOutstandingExpectations` method
* can be used to check if any expectations have not yet been met.
*
* The response given will be returned if the expectation matches.
*/
expect(url: string, response: string): void;
/**
* Add a definition for the given URL to return the given response. Unlike expectations,
* definitions have no order and will satisfy any matching request at any time. Also
* unlike expectations, unused definitions do not cause `verifyNoOutstandingExpectations`
* to return an error.
*/
when(url: string, response: string): void;
/**
* Process pending requests and verify there are no outstanding expectations. Also fails
* if no requests are pending.
*/
flush(): void;
/**
* Throw an exception if any expectations have not been satisfied.
*/
verifyNoOutstandingExpectations(): void;
private _processRequest;
}