Files
Angular-Cn/modules/angular2/src/testing/async_test_completer.ts
T
Vikram Subramanian 35cd0ded22 chore(testing): Refactor test methods to have a uniform interface.
Remove FunctionWithParamTokens.

All test wrappers async, fakeAsync and inject now return just a Function instead of FunctionWithParamTokens. This makes them directly consumable by the test framework. Also the test framework code does not have to handle a union of Function and FunctionWithParamTokens everywhere.

The Function returned by the above methods are considered asynchronous by the test framework if they return a Promise, synchronous otherwise.

Closes #8257
2016-04-28 01:16:25 +00:00

14 lines
470 B
TypeScript

import {PromiseCompleter} from 'angular2/src/facade/promise';
/**
* Injectable completer that allows signaling completion of an asynchronous test. Used internally.
*/
export class AsyncTestCompleter {
private _completer = new PromiseCompleter<any>();
done(value?: any) { this._completer.resolve(value); }
fail(error?: any, stackTrace?: string) { this._completer.reject(error, stackTrace); }
get promise(): Promise<any> { return this._completer.promise; }
}