docs(*): Document a lot more symbols that are missing comments in our generated docs.

This commit is contained in:
Alex Rickabaugh
2015-12-03 15:49:09 -08:00
parent 5a04ffec3e
commit 80a5e47e61
65 changed files with 793 additions and 22 deletions

View File

@ -4,6 +4,10 @@ import {isBlank, isPresent, normalizeBlank} from 'angular2/src/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
import {PromiseCompleter, PromiseWrapper, Promise} from 'angular2/src/facade/async';
/**
* A mock implemenation of {@link XHR} that allows outgoing requests to be mocked
* and responded to within a single test, without going to the network.
*/
export class MockXHR extends XHR {
private _expectations: _Expectation[] = [];
private _definitions = new Map<string, string>();
@ -15,13 +19,30 @@ export class MockXHR extends XHR {
return request.getPromise();
}
/**
* 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) {
var expectation = new _Expectation(url, response);
this._expectations.push(expectation);
}
/**
* 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) { this._definitions.set(url, response); }
/**
* Process pending requests and verify there are no outstanding expectations. Also fails
* if no requests are pending.
*/
flush() {
if (this._requests.length === 0) {
throw new BaseException('No pending requests to flush');
@ -34,6 +55,9 @@ export class MockXHR extends XHR {
this.verifyNoOutstandingExpectations();
}
/**
* Throw an exception if any expectations have not been satisfied.
*/
verifyNoOutstandingExpectations() {
if (this._expectations.length === 0) return;