OLD | NEW |
1 library ng_bind_route_spec; | 1 library ng_bind_route_spec; |
2 | 2 |
3 import 'dart:html'; | 3 import 'dart:html'; |
4 import '../_specs.dart'; | 4 import '../_specs.dart'; |
5 import 'package:angular/routing/module.dart'; | 5 import 'package:angular/routing/module.dart'; |
6 import 'package:angular/mock/module.dart'; | 6 import 'package:angular/mock/module.dart'; |
7 | 7 |
8 main() { | 8 main() { |
9 describe('ngBindRoute', () { | 9 describe('ngBindRoute', () { |
10 TestBed _; | 10 TestBed _; |
11 | 11 |
12 beforeEach(module((Module m) => m | 12 beforeEachModule((Module m) => m |
13 ..install(new AngularMockModule()) | 13 ..install(new AngularMockModule()) |
14 ..type(RouteInitializerFn, implementedBy: NestedRouteInitializer))); | 14 ..type(RouteInitializerFn, implementedBy: NestedRouteInitializer)); |
15 | 15 |
16 beforeEach(inject((TestBed tb) { | 16 beforeEach((TestBed tb) { |
17 _ = tb; | 17 _ = tb; |
18 })); | 18 }); |
19 | 19 |
20 | 20 |
21 it('should inject null RouteProvider when no ng-bind-route', async(() { | 21 it('should inject null RouteProvider when no ng-bind-route', async(() { |
22 Element root = _.compile('<div probe="routeProbe"></div>'); | 22 Element root = _.compile('<div probe="routeProbe"></div>'); |
23 expect(_.rootScope.context['routeProbe'].injector.get(RouteProvider)).toBe
Null(); | 23 expect(_.rootScope.context['routeProbe'].injector.get(RouteProvider)).toBe
Null(); |
24 })); | 24 })); |
25 | 25 |
26 | 26 |
27 it('should inject RouteProvider with correct flat route', async(() { | 27 it('should inject RouteProvider with correct flat route', async(() { |
28 Element root = _.compile( | 28 Element root = _.compile( |
(...skipping 11 matching lines...) Expand all Loading... |
40 ' </div>' | 40 ' </div>' |
41 '</div>'); | 41 '</div>'); |
42 expect(_.rootScope.context['routeProbe'].injector.get(RouteProvider).route
.name) | 42 expect(_.rootScope.context['routeProbe'].injector.get(RouteProvider).route
.name) |
43 .toEqual('all'); | 43 .toEqual('all'); |
44 })); | 44 })); |
45 | 45 |
46 }); | 46 }); |
47 } | 47 } |
48 | 48 |
49 class NestedRouteInitializer implements Function { | 49 class NestedRouteInitializer implements Function { |
50 void call(Router router, ViewFactory view) { | 50 void call(Router router, RouteViewFactory view) { |
51 router.root | 51 router.root |
52 ..addRoute( | 52 ..addRoute( |
53 name: 'library', | 53 name: 'library', |
54 path: '/library', | 54 path: '/library', |
55 enter: view('library.html'), | 55 enter: view('library.html'), |
56 mount: (Route route) => route | 56 mount: (Route route) => route |
57 ..addRoute( | 57 ..addRoute( |
58 name: 'all', | 58 name: 'all', |
59 path: '/all', | 59 path: '/all', |
60 enter: view('book_list.html')) | 60 enter: view('book_list.html')) |
61 ..addRoute( | 61 ..addRoute( |
62 name: 'book', | 62 name: 'book', |
63 path: '/:bookId', | 63 path: '/:bookId', |
64 mount: (Route route) => route | 64 mount: (Route route) => route |
65 ..addRoute( | 65 ..addRoute( |
66 name: 'overview', | 66 name: 'overview', |
67 path: '/overview', | 67 path: '/overview', |
68 defaultRoute: true, | 68 defaultRoute: true, |
69 enter: view('book_overview.html')) | 69 enter: view('book_overview.html')) |
70 ..addRoute( | 70 ..addRoute( |
71 name: 'read', | 71 name: 'read', |
72 path: '/read', | 72 path: '/read', |
73 enter: view('book_read.html')))) | 73 enter: view('book_read.html')))) |
74 ..addRoute( | 74 ..addRoute( |
75 name: 'admin', | 75 name: 'admin', |
76 path: '/admin', | 76 path: '/admin', |
77 enter: view('admin.html')); | 77 enter: view('admin.html')); |
78 } | 78 } |
79 } | 79 } |
OLD | NEW |