| OLD | NEW |
| 1 library zone_spec; | 1 library zone_spec; |
| 2 | 2 |
| 3 import '../_specs.dart'; | 3 import '../_specs.dart'; |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 main() => describe('zone', () { | 7 main() => describe('zone', () { |
| 8 var zone; | 8 var zone; |
| 9 var exceptionHandler; | 9 var exceptionHandler; |
| 10 beforeEach(module((Module module) { | 10 beforeEach(module((Module module) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 scheduleMicrotask(() { | 39 scheduleMicrotask(() { |
| 40 throw ["async exception"]; | 40 throw ["async exception"]; |
| 41 }); | 41 }); |
| 42 }); | 42 }); |
| 43 | 43 |
| 44 expect(exceptionHandler.errors.length).toEqual(1); | 44 expect(exceptionHandler.errors.length).toEqual(1); |
| 45 expect(exceptionHandler.errors[0].error).toEqual(["async exception"]); | 45 expect(exceptionHandler.errors[0].error).toEqual(["async exception"]); |
| 46 }))); | 46 }))); |
| 47 | 47 |
| 48 | 48 |
| 49 it('should allow executing code outside the zone', inject(() { | |
| 50 var zone = new NgZone(); | |
| 51 var outerZone = Zone.current; | |
| 52 var ngZone; | |
| 53 var outsideZone; | |
| 54 zone.run(() { | |
| 55 ngZone = Zone.current; | |
| 56 zone.runOutsideAngular(() { | |
| 57 outsideZone = Zone.current; | |
| 58 }); | |
| 59 }); | |
| 60 | |
| 61 expect(outsideZone).toEqual(outerZone); | |
| 62 expect(ngZone.parent).toEqual((outerZone)); | |
| 63 })); | |
| 64 | |
| 65 | |
| 66 it('should rethrow exceptions from the onTurnDone and call onError when the
zone is sync', () { | 49 it('should rethrow exceptions from the onTurnDone and call onError when the
zone is sync', () { |
| 67 zone.onTurnDone = () { | 50 zone.onTurnDone = () { |
| 68 throw ["fromOnTurnDone"]; | 51 throw ["fromOnTurnDone"]; |
| 69 }; | 52 }; |
| 70 | 53 |
| 71 expect(() { | 54 expect(() { |
| 72 zone.run(() { }); | 55 zone.run(() { }); |
| 73 }).toThrow('fromOnTurnDone'); | 56 }).toThrow('fromOnTurnDone'); |
| 74 | 57 |
| 75 expect(exceptionHandler.errors.length).toEqual(1); | 58 expect(exceptionHandler.errors.length).toEqual(1); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 })); | 335 })); |
| 353 | 336 |
| 354 | 337 |
| 355 it('should assertInTurn outside of the zone', () { | 338 it('should assertInTurn outside of the zone', () { |
| 356 expect(async(() { | 339 expect(async(() { |
| 357 zone.assertInTurn(); | 340 zone.assertInTurn(); |
| 358 microLeap(); | 341 microLeap(); |
| 359 })).toThrow('ssertion'); // Support both dart2js and the VM with half a wor
d. | 342 })).toThrow('ssertion'); // Support both dart2js and the VM with half a wor
d. |
| 360 }); | 343 }); |
| 361 }); | 344 }); |
| OLD | NEW |