(Zone: ZoneType)
| 9 | import {ZoneType} from '../zone-impl'; |
| 10 | |
| 11 | export 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 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…