@ -22,7 +22,9 @@ Zone.__load_patch('asynctest', (global: any, Zone: ZoneType, api: _ZonePrivate)
|
||||
// if we run beforeEach in @angular/core/testing/testing_internal then we get no done
|
||||
// fake it here and assume sync.
|
||||
done = function() {};
|
||||
done.fail = function(e: any) { throw e; };
|
||||
done.fail = function(e: any) {
|
||||
throw e;
|
||||
};
|
||||
}
|
||||
runInTestZone(fn, this, done, (err: any) => {
|
||||
if (typeof err === 'string') {
|
||||
@ -68,7 +70,7 @@ Zone.__load_patch('asynctest', (global: any, Zone: ZoneType, api: _ZonePrivate)
|
||||
// If we do it in ProxyZone then we will get to infinite recursion.
|
||||
const proxyZone = Zone.current.getZoneWith('ProxyZoneSpec');
|
||||
const previousDelegate = proxyZoneSpec.getDelegate();
|
||||
proxyZone !.parent !.run(() => {
|
||||
proxyZone!.parent!.run(() => {
|
||||
const testZoneSpec: ZoneSpec = new AsyncTestZoneSpec(
|
||||
() => {
|
||||
// Need to restore the original zone.
|
||||
@ -79,7 +81,9 @@ Zone.__load_patch('asynctest', (global: any, Zone: ZoneType, api: _ZonePrivate)
|
||||
proxyZoneSpec.setDelegate(previousDelegate);
|
||||
}
|
||||
(testZoneSpec as any).unPatchPromiseForTest();
|
||||
currentZone.run(() => { finishCallback(); });
|
||||
currentZone.run(() => {
|
||||
finishCallback();
|
||||
});
|
||||
},
|
||||
(error: any) => {
|
||||
// Need to restore the original zone.
|
||||
@ -88,7 +92,9 @@ Zone.__load_patch('asynctest', (global: any, Zone: ZoneType, api: _ZonePrivate)
|
||||
proxyZoneSpec.setDelegate(previousDelegate);
|
||||
}
|
||||
(testZoneSpec as any).unPatchPromiseForTest();
|
||||
currentZone.run(() => { failCallback(error); });
|
||||
currentZone.run(() => {
|
||||
failCallback(error);
|
||||
});
|
||||
},
|
||||
'test');
|
||||
proxyZoneSpec.setDelegate(testZoneSpec);
|
||||
|
@ -131,7 +131,9 @@ Zone.__load_patch('fakeasync', (global: any, Zone: ZoneType, api: _ZonePrivate)
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
function flush(maxTurns?: number): number { return _getFakeAsyncZoneSpec().flush(maxTurns); }
|
||||
function flush(maxTurns?: number): number {
|
||||
return _getFakeAsyncZoneSpec().flush(maxTurns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Discard all remaining periodic tasks.
|
||||
@ -149,7 +151,9 @@ Zone.__load_patch('fakeasync', (global: any, Zone: ZoneType, api: _ZonePrivate)
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
function flushMicrotasks(): void { _getFakeAsyncZoneSpec().flushMicrotasks(); }
|
||||
(Zone as any)[api.symbol('fakeAsyncTest')] = {
|
||||
resetFakeAsyncZone, flushMicrotasks, discardPeriodicTasks, tick, flush, fakeAsync};
|
||||
function flushMicrotasks(): void {
|
||||
_getFakeAsyncZoneSpec().flushMicrotasks();
|
||||
}
|
||||
(Zone as any)[api.symbol('fakeAsyncTest')] =
|
||||
{resetFakeAsyncZone, flushMicrotasks, discardPeriodicTasks, tick, flush, fakeAsync};
|
||||
});
|
||||
|
Reference in New Issue
Block a user