license import '../zone-spec/async-test' ; Zone . __load_patch ( 'asynctest' , ( global , Zone , api ) => { /**
     * Wraps a test function in an asynchronous test zone. The test will automatically
     * complete when all asynchronous calls within this zone are done.
     */ ( Zone as any ) [ api . symbol ( 'asyncTest' ) ] = function asyncTest ( fn ) : ( done : any ) => any { if ( global . jasmine ) { return function ( done ) { if ( ! done ) { done = function ( ) { } ; done . fail = function ( e ) { throw e ; } ; } runInTestZone ( fn , this , done , ( err ) => { if ( typeof err === 'string' ) { return done . fail ( new Error ( < string > err ) ) ; } else { done . fail ( err ) ; } } ) ; } ; } return function ( ) { return new Promise < void > ( ( finishCallback , failCallback ) => { runInTestZone ( fn , this , finishCallback , failCallback ) ; } ) ; } ; } ; function runInTestZone ( fn , context , finishCallback , failCallback ) { const currentZone = Zone . current ; const AsyncTestZoneSpec = ( Zone as any ) [ 'AsyncTestZoneSpec' ] ; if ( AsyncTestZoneSpec === undefined ) { throw new Error ( 'AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + 'Please make sure that your environment includes zone.js/dist/async-test.js' ) ; } const ProxyZoneSpec = ( Zone as any ) [ 'ProxyZoneSpec' ] as { get ( ) : { setDelegate ( spec ) : void ; getDelegate ( ) : ZoneSpec ; } ; assertPresent : ( ) => void ; } ; if ( ProxyZoneSpec === undefined ) { throw new Error ( 'ProxyZoneSpec is needed for the async() test helper but could not be found. ' + 'Please make sure that your environment includes zone.js/dist/proxy.js' ) ; } const proxyZoneSpec = ProxyZoneSpec . get ( ) ; ProxyZoneSpec . assertPresent ( ) ; const proxyZone = Zone . current . getZoneWith ( 'ProxyZoneSpec' ) ; const previousDelegate = proxyZoneSpec . getDelegate ( ) ; proxyZone ! . parent ! . run ( ( ) => { const testZoneSpec = new AsyncTestZoneSpec ( ( ) => { if ( proxyZoneSpec . getDelegate ( ) == testZoneSpec ) { proxyZoneSpec . setDelegate ( previousDelegate ) ; } ( testZoneSpec as any ) . unPatchPromiseForTest ( ) ; currentZone . run ( ( ) => { finishCallback ( ) ; } ) ; } , ( error ) => { if ( proxyZoneSpec . getDelegate ( ) == testZoneSpec ) { proxyZoneSpec . setDelegate ( previousDelegate ) ; } ( testZoneSpec as any ) . unPatchPromiseForTest ( ) ; currentZone . run ( ( ) => { failCallback ( error ) ; } ) ; } , 'test' ) ; proxyZoneSpec . setDelegate ( testZoneSpec ) ; ( testZoneSpec as any ) . patchPromiseForTest ( ) ; } ) ; return Zone . current . runGuarded ( fn , context ) ; } } ) ;