Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: third_party/pkg/angular/test/routing/ng_view_spec.dart

Issue 180843004: Revert revision 33053 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 library ng_view_spec; 1 library ng_view_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('Flat ngView', () { 9 describe('Flat ngView', () {
10 TestBed _; 10 TestBed _;
11 Router router; 11 Router router;
12 12
13 beforeEach(module((Module m) { 13 beforeEach(module((Module m) {
14 m 14 m
15 ..install(new AngularMockModule()) 15 ..install(new AngularMockModule())
16 ..type(RouteInitializerFn, implementedBy: FlatRouteInitializer); 16 ..type(RouteInitializer, implementedBy: FlatRouteInitializer);
17 })); 17 }));
18 18
19 beforeEach(inject((TestBed tb, Router _router, TemplateCache templates) { 19 beforeEach(inject((TestBed tb, Router _router, TemplateCache templates) {
20 _ = tb; 20 _ = tb;
21 router = _router; 21 router = _router;
22 22
23 templates.put('foo.html', new HttpResponse(200, 23 templates.put('foo.html', new HttpResponse(200,
24 '<h1>Foo</h1>')); 24 '<h1>Foo</h1>'));
25 templates.put('bar.html', new HttpResponse(200, 25 templates.put('bar.html', new HttpResponse(200,
26 '<h1>Bar</h1>')); 26 '<h1>Bar</h1>'));
(...skipping 20 matching lines...) Expand all
47 47
48 it('should switch template when route is already active', async(() { 48 it('should switch template when route is already active', async(() {
49 // Force the routing system to initialize. 49 // Force the routing system to initialize.
50 _.compile('<ng-view></ng-view>'); 50 _.compile('<ng-view></ng-view>');
51 51
52 router.route('/foo'); 52 router.route('/foo');
53 microLeap(); 53 microLeap();
54 Element root = _.compile('<ng-view></ng-view>'); 54 Element root = _.compile('<ng-view></ng-view>');
55 expect(root.text).toEqual(''); 55 expect(root.text).toEqual('');
56 56
57 _.rootScope.apply(); 57 _.rootScope.$digest();
58 microLeap(); 58 microLeap();
59 expect(root.text).toEqual('Foo'); 59 expect(root.text).toEqual('Foo');
60 })); 60 }));
61 61
62 62
63 it('should clear template when route is deactivated', async(() { 63 it('should clear template when route is deactivated', async(() {
64 Element root = _.compile('<ng-view></ng-view>'); 64 Element root = _.compile('<ng-view></ng-view>');
65 expect(root.text).toEqual(''); 65 expect(root.text).toEqual('');
66 66
67 router.route('/foo'); 67 router.route('/foo');
68 microLeap(); 68 microLeap();
69 expect(root.text).toEqual('Foo'); 69 expect(root.text).toEqual('Foo');
70 70
71 router.route('/baz'); // route without a template 71 router.route('/baz'); // route without a template
72 microLeap(); 72 microLeap();
73 expect(root.text).toEqual(''); 73 expect(root.text).toEqual('');
74 })); 74 }));
75 75
76 }); 76 });
77 77
78 78
79 describe('Nested ngView', () { 79 describe('Nested ngView', () {
80 TestBed _; 80 TestBed _;
81 Router router; 81 Router router;
82 82
83 beforeEach(module((Module m) { 83 beforeEach(module((Module m) {
84 m 84 m
85 ..install(new AngularMockModule()) 85 ..install(new AngularMockModule())
86 ..type(RouteInitializerFn, implementedBy: NestedRouteInitializer); 86 ..type(RouteInitializer, implementedBy: NestedRouteInitializer);
87 })); 87 }));
88 88
89 beforeEach(inject((TestBed tb, Router _router, TemplateCache templates) { 89 beforeEach(inject((TestBed tb, Router _router, TemplateCache templates) {
90 _ = tb; 90 _ = tb;
91 router = _router; 91 router = _router;
92 92
93 templates.put('library.html', new HttpResponse(200, 93 templates.put('library.html', new HttpResponse(200,
94 '<div><h1>Library</h1>' 94 '<div><h1>Library</h1>'
95 '<ng-view></ng-view></div>')); 95 '<ng-view></ng-view></div>'));
96 templates.put('book_list.html', new HttpResponse(200, 96 templates.put('book_list.html', new HttpResponse(200,
(...skipping 24 matching lines...) Expand all
121 121
122 // nothing should change here 122 // nothing should change here
123 router.route('/library/1234/read'); 123 router.route('/library/1234/read');
124 microLeap(); 124 microLeap();
125 expect(root.text).toEqual('LibraryRead Book 1234'); 125 expect(root.text).toEqual('LibraryRead Book 1234');
126 })); 126 }));
127 127
128 }); 128 });
129 } 129 }
130 130
131 class FlatRouteInitializer implements Function { 131 class FlatRouteInitializer implements RouteInitializer {
132 void call(Router router, ViewFactory view) { 132 void init(Router router, ViewFactory view) {
133 router.root 133 router.root
134 ..addRoute( 134 ..addRoute(
135 name: 'foo', 135 name: 'foo',
136 path: '/foo', 136 path: '/foo',
137 enter: view('foo.html')) 137 enter: view('foo.html'))
138 ..addRoute( 138 ..addRoute(
139 name: 'bar', 139 name: 'bar',
140 path: '/bar', 140 path: '/bar',
141 enter: view('bar.html')) 141 enter: view('bar.html'))
142 ..addRoute( 142 ..addRoute(
143 name: 'baz', 143 name: 'baz',
144 path: '/baz'); // route without a template 144 path: '/baz'); // route without a template
145 } 145 }
146 } 146 }
147 147
148 class NestedRouteInitializer implements Function { 148 class NestedRouteInitializer implements RouteInitializer {
149 void call(Router router, ViewFactory view) { 149 void init(Router router, ViewFactory view) {
150 router.root 150 router.root
151 ..addRoute( 151 ..addRoute(
152 name: 'library', 152 name: 'library',
153 path: '/library', 153 path: '/library',
154 enter: view('library.html'), 154 enter: view('library.html'),
155 mount: (Route route) => route 155 mount: (Route route) => route
156 ..addRoute( 156 ..addRoute(
157 name: 'all', 157 name: 'all',
158 path: '/all', 158 path: '/all',
159 enter: view('book_list.html')) 159 enter: view('book_list.html'))
160 ..addRoute( 160 ..addRoute(
161 name: 'book', 161 name: 'book',
162 path: '/:bookId', 162 path: '/:bookId',
163 mount: (Route route) => route 163 mount: (Route route) => route
164 ..addRoute( 164 ..addRoute(
165 name: 'overview', 165 name: 'overview',
166 path: '/overview', 166 path: '/overview',
167 defaultRoute: true, 167 defaultRoute: true,
168 enter: view('book_overview.html')) 168 enter: view('book_overview.html'))
169 ..addRoute( 169 ..addRoute(
170 name: 'read', 170 name: 'read',
171 path: '/read', 171 path: '/read',
172 enter: view('book_read.html')))) 172 enter: view('book_read.html'))))
173 ..addRoute( 173 ..addRoute(
174 name: 'admin', 174 name: 'admin',
175 path: '/admin', 175 path: '/admin',
176 enter: view('admin.html')); 176 enter: view('admin.html'));
177 } 177 }
178 } 178 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/test/routing/ng_bind_route_spec.dart ('k') | third_party/pkg/angular/test/routing/routing_spec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698