mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-23 23:59:27 +08:00
Those 2 packages were still using the wrong scope (@angular-cli) and were not used by anyone outside the CLI. Just moving the code in the main package is enough.
27 lines
690 B
TypeScript
27 lines
690 B
TypeScript
// This file exports a version of the Jasmine `it` that understands promises.
|
|
// To use this, simply `import {it} from './spec-utils`.
|
|
// TODO(hansl): move this to its own Jasmine-TypeScript package.
|
|
|
|
function async(fn: () => PromiseLike<any> | void) {
|
|
return (done: DoneFn) => {
|
|
let result: PromiseLike<any> | void = null;
|
|
|
|
try {
|
|
result = fn();
|
|
|
|
if (result && 'then' in result) {
|
|
(result as Promise<any>).then(done, done.fail);
|
|
} else {
|
|
done();
|
|
}
|
|
} catch (err) {
|
|
done.fail(err);
|
|
}
|
|
};
|
|
}
|
|
|
|
|
|
export function it(description: string, fn: () => PromiseLike<any> | void) {
|
|
return (global as any)['it'](description, async(fn));
|
|
}
|