Bones/node_modules/zone.js/lib/zone-spec/sync-test.ts

30 lines
782 B
TypeScript
Raw Normal View History

2017-05-17 13:45:25 -04:00
(function() {
class SyncTestZoneSpec implements ZoneSpec {
runZone = Zone.current;
constructor(namePrefix: string) {
this.name = 'syncTestZone for ' + namePrefix;
}
// ZoneSpec implementation below.
name: string;
onScheduleTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): Task {
switch (task.type) {
case 'microTask':
case 'macroTask':
throw new Error(`Cannot call ${task.source} from within a sync test.`);
case 'eventTask':
task = delegate.scheduleTask(target, task);
break;
}
return task;
}
}
// Export the class so that new instances can be created with proper
// constructor params.
Zone['SyncTestZoneSpec'] = SyncTestZoneSpec;
})();