MCPcopy Index your code
hub / github.com/angular/angular / patchSyncTest

Function patchSyncTest

packages/zone.js/lib/zone-spec/sync-test.ts:11–39  ·  view source on GitHub ↗
(Zone: ZoneType)

Source from the content-addressed store, hash-verified

9import {ZoneType} from '../zone-impl';
10
11export function patchSyncTest(Zone: ZoneType): void {
12 class SyncTestZoneSpec implements ZoneSpec {
13 runZone = Zone.current;
14
15 constructor(namePrefix: string) {
16 this.name = 'syncTestZone for ' + namePrefix;
17 }
18
19 // ZoneSpec implementation below.
20
21 name: string;
22
23 onScheduleTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): Task {
24 switch (task.type) {
25 case 'microTask':
26 case 'macroTask':
27 throw new Error(`Cannot call ${task.source} from within a sync test (${this.name}).`);
28 case 'eventTask':
29 task = delegate.scheduleTask(target, task);
30 break;
31 }
32 return task;
33 }
34 }
35
36 // Export the class so that new instances can be created with proper
37 // constructor params.
38 (Zone as any)['SyncTestZoneSpec'] = SyncTestZoneSpec;
39}

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…