sync-test.js 805 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. /**
  3. * @license Angular v<unknown>
  4. * (c) 2010-2022 Google LLC. https://angular.io/
  5. * License: MIT
  6. */
  7. class SyncTestZoneSpec {
  8. constructor(namePrefix) {
  9. this.runZone = Zone.current;
  10. this.name = 'syncTestZone for ' + namePrefix;
  11. }
  12. onScheduleTask(delegate, current, target, task) {
  13. switch (task.type) {
  14. case 'microTask':
  15. case 'macroTask':
  16. throw new Error(`Cannot call ${task.source} from within a sync test (${this.name}).`);
  17. case 'eventTask':
  18. task = delegate.scheduleTask(target, task);
  19. break;
  20. }
  21. return task;
  22. }
  23. }
  24. // Export the class so that new instances can be created with proper
  25. // constructor params.
  26. Zone['SyncTestZoneSpec'] = SyncTestZoneSpec;