Hans c889dd8e94 refactor(@angular-cli): get rid of ast-tools and base-href-webpack (#4411)
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.
2017-02-03 22:57:42 -08:00

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));
}