| OLD | NEW |
| (Empty) | |
| 1 library routing_spec; |
| 2 |
| 3 import '../_specs.dart'; |
| 4 import 'package:angular/routing/module.dart'; |
| 5 import 'package:angular/mock/module.dart'; |
| 6 |
| 7 main() { |
| 8 describe('routing', () { |
| 9 TestBed _; |
| 10 TestRouteInitializer initer; |
| 11 Router router; |
| 12 |
| 13 beforeEach(module((Module m) { |
| 14 router = new Router(useFragment: false, windowImpl: new MockWindow()); |
| 15 m |
| 16 ..install(new AngularMockModule()) |
| 17 ..type(RouteInitializer, implementedBy: TestRouteInitializer) |
| 18 ..value(Router, router); |
| 19 })); |
| 20 |
| 21 beforeEach(inject((TestBed tb, RouteInitializer _initer) { |
| 22 _ = tb; |
| 23 initer = _initer; |
| 24 })); |
| 25 |
| 26 |
| 27 it('should call init of the RouteInitializer once', async(() { |
| 28 expect(initer.calledInit).toEqual(0); |
| 29 |
| 30 // Force the routing system to initialize. |
| 31 _.compile('<ng-view></ng-view>'); |
| 32 |
| 33 expect(initer.calledInit).toEqual(1); |
| 34 expect(initer.router).toBe(router); |
| 35 })); |
| 36 |
| 37 }); |
| 38 } |
| 39 |
| 40 class TestRouteInitializer implements RouteInitializer { |
| 41 int calledInit = 0; |
| 42 Router router; |
| 43 |
| 44 void init(Router router, ViewFactory view) { |
| 45 calledInit++; |
| 46 this.router = router; |
| 47 } |
| 48 } |
| OLD | NEW |