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

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

Issue 256553002: Revert "Update all Angular libs (run update_all.sh)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 beforeEachModule((Module module) { 13 beforeEach(module((Module m) {
14 module 14 m
15 ..install(new AngularMockModule()) 15 ..install(new AngularMockModule())
16 ..type(RouteInitializerFn, implementedBy: FlatRouteInitializer); 16 ..type(RouteInitializerFn, implementedBy: FlatRouteInitializer);
17 }); 17 }));
18 18
19 beforeEach((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>'));
27 }); 27 }));
28 28
29 29
30 it('should switch template', async(() { 30 it('should switch template', async(() {
31 Element root = _.compile('<div><ng-view></ng-view></div>'); 31 Element root = _.compile('<ng-view></ng-view>');
32 expect(root.text).toEqual(''); 32 expect(root.text).toEqual('');
33 33
34 router.route('/foo'); 34 router.route('/foo');
35 microLeap(); 35 microLeap();
36 _.rootScope.apply();
37 expect(root.text).toEqual('Foo'); 36 expect(root.text).toEqual('Foo');
38 37
39 router.route('/bar'); 38 router.route('/bar');
40 microLeap(); 39 microLeap();
41 _.rootScope.apply();
42 expect(root.text).toEqual('Bar'); 40 expect(root.text).toEqual('Bar');
43 41
44 router.route('/foo'); 42 router.route('/foo');
45 microLeap(); 43 microLeap();
46 _.rootScope.apply();
47 expect(root.text).toEqual('Foo'); 44 expect(root.text).toEqual('Foo');
48 })); 45 }));
49 46
50 47
51 it('should switch template when route is already active', async(() { 48 it('should switch template when route is already active', async(() {
52 // Force the routing system to initialize. 49 // Force the routing system to initialize.
53 _.compile('<div><ng-view></ng-view></div>'); 50 _.compile('<ng-view></ng-view>');
54 51
55 router.route('/foo'); 52 router.route('/foo');
56 microLeap(); 53 microLeap();
57 Element root = _.compile('<div><ng-view></ng-view></div>'); 54 Element root = _.compile('<ng-view></ng-view>');
58 expect(root.text).toEqual(''); 55 expect(root.text).toEqual('');
59 56
57 _.rootScope.apply();
60 microLeap(); 58 microLeap();
61 _.rootScope.apply();
62 expect(root.text).toEqual('Foo'); 59 expect(root.text).toEqual('Foo');
63 })); 60 }));
64 61
65 62
66 it('should clear template when route is deactivated', async(() { 63 it('should clear template when route is deactivated', async(() {
67 Element root = _.compile('<div><ng-view></ng-view></div>'); 64 Element root = _.compile('<ng-view></ng-view>');
68 expect(root.text).toEqual(''); 65 expect(root.text).toEqual('');
69 66
70 router.route('/foo'); 67 router.route('/foo');
71 microLeap(); 68 microLeap();
72 _.rootScope.apply();
73 expect(root.text).toEqual('Foo'); 69 expect(root.text).toEqual('Foo');
74 70
75 router.route('/baz'); // route without a template 71 router.route('/baz'); // route without a template
76 microLeap(); 72 microLeap();
77 _.rootScope.apply();
78 expect(root.text).toEqual(''); 73 expect(root.text).toEqual('');
79 })); 74 }));
80 75
81 }); 76 });
82 77
83 78
84 describe('Nested ngView', () { 79 describe('Nested ngView', () {
85 TestBed _; 80 TestBed _;
86 Router router; 81 Router router;
87 82
88 beforeEachModule((Module module) { 83 beforeEach(module((Module m) {
89 module 84 m
90 ..install(new AngularMockModule()) 85 ..install(new AngularMockModule())
91 ..type(RouteInitializerFn, implementedBy: NestedRouteInitializer); 86 ..type(RouteInitializerFn, implementedBy: NestedRouteInitializer);
92 }); 87 }));
93 88
94 beforeEach((TestBed tb, Router _router, TemplateCache templates) { 89 beforeEach(inject((TestBed tb, Router _router, TemplateCache templates) {
95 _ = tb; 90 _ = tb;
96 router = _router; 91 router = _router;
97 92
98 templates.put('library.html', new HttpResponse(200, 93 templates.put('library.html', new HttpResponse(200,
99 '<div><h1>Library</h1>' 94 '<div><h1>Library</h1>'
100 '<ng-view></ng-view></div>')); 95 '<ng-view></ng-view></div>'));
101 templates.put('book_list.html', new HttpResponse(200, 96 templates.put('book_list.html', new HttpResponse(200,
102 '<h1>Books</h1>')); 97 '<h1>Books</h1>'));
103 templates.put('book_overview.html', new HttpResponse(200, 98 templates.put('book_overview.html', new HttpResponse(200,
104 '<h2>Book 1234</h2>')); 99 '<h2>Book 1234</h2>'));
105 templates.put('book_read.html', new HttpResponse(200, 100 templates.put('book_read.html', new HttpResponse(200,
106 '<h2>Read Book 1234</h2>')); 101 '<h2>Read Book 1234</h2>'));
107 }); 102 }));
103
108 104
109 it('should switch nested templates', async(() { 105 it('should switch nested templates', async(() {
110 Element root = _.compile('<div><ng-view></ng-view></div>'); 106 Element root = _.compile('<ng-view></ng-view>');
111 expect(root.text).toEqual(''); 107 expect(root.text).toEqual('');
112 108
113 router.route('/library/all'); 109 router.route('/library/all');
114 microLeap(); 110 microLeap();
115 _.rootScope.apply();
116 expect(root.text).toEqual('LibraryBooks'); 111 expect(root.text).toEqual('LibraryBooks');
117 112
118 router.route('/library/1234'); 113 router.route('/library/1234');
119 microLeap(); 114 microLeap();
120 _.rootScope.apply();
121 expect(root.text).toEqual('LibraryBook 1234'); 115 expect(root.text).toEqual('LibraryBook 1234');
122 116
123 // nothing should change here 117 // nothing should change here
124 router.route('/library/1234/overview'); 118 router.route('/library/1234/overview');
125 microLeap(); 119 microLeap();
126 _.rootScope.apply();
127 expect(root.text).toEqual('LibraryBook 1234'); 120 expect(root.text).toEqual('LibraryBook 1234');
128 121
129 // nothing should change here 122 // nothing should change here
130 router.route('/library/1234/read'); 123 router.route('/library/1234/read');
131 microLeap(); 124 microLeap();
132 _.rootScope.apply();
133 expect(root.text).toEqual('LibraryRead Book 1234'); 125 expect(root.text).toEqual('LibraryRead Book 1234');
134 })); 126 }));
135 });
136 127
137
138 describe('Inline template ngView', () {
139 TestBed _;
140 Router router;
141
142 beforeEachModule((Module module) {
143 module
144 ..install(new AngularMockModule())
145 ..value(RouteInitializerFn, (router, views) {
146 views.configure({
147 'foo': ngRoute(
148 path: '/foo',
149 viewHtml: '<h1>Hello</h1>')
150 });
151 });
152 });
153
154 beforeEach((TestBed tb, Router _router, TemplateCache templates) {
155 _ = tb;
156 router = _router;
157 });
158
159 it('should switch inline templates', async(() {
160 Element root = _.compile('<div><ng-view></ng-view></div>');
161 expect(root.text).toEqual('');
162
163 router.route('/foo');
164 microLeap();
165 _.rootScope.apply();
166 expect(root.text).toEqual('Hello');
167 }));
168 }); 128 });
169 } 129 }
170 130
171 class FlatRouteInitializer implements Function { 131 class FlatRouteInitializer implements Function {
172 void call(Router router, RouteViewFactory view) { 132 void call(Router router, ViewFactory view) {
173 router.root 133 router.root
174 ..addRoute( 134 ..addRoute(
175 name: 'foo', 135 name: 'foo',
176 path: '/foo', 136 path: '/foo',
177 enter: view('foo.html')) 137 enter: view('foo.html'))
178 ..addRoute( 138 ..addRoute(
179 name: 'bar', 139 name: 'bar',
180 path: '/bar', 140 path: '/bar',
181 enter: view('bar.html')) 141 enter: view('bar.html'))
182 ..addRoute( 142 ..addRoute(
183 name: 'baz', 143 name: 'baz',
184 path: '/baz'); // route without a template 144 path: '/baz'); // route without a template
185 } 145 }
186 } 146 }
187 147
188 class NestedRouteInitializer implements Function { 148 class NestedRouteInitializer implements Function {
189 void call(Router router, RouteViewFactory view) { 149 void call(Router router, ViewFactory view) {
190 router.root 150 router.root
191 ..addRoute( 151 ..addRoute(
192 name: 'library', 152 name: 'library',
193 path: '/library', 153 path: '/library',
194 enter: view('library.html'), 154 enter: view('library.html'),
195 mount: (Route route) => route 155 mount: (Route route) => route
196 ..addRoute( 156 ..addRoute(
197 name: 'all', 157 name: 'all',
198 path: '/all', 158 path: '/all',
199 enter: view('book_list.html')) 159 enter: view('book_list.html'))
200 ..addRoute( 160 ..addRoute(
201 name: 'book', 161 name: 'book',
202 path: '/:bookId', 162 path: '/:bookId',
203 mount: (Route route) => route 163 mount: (Route route) => route
204 ..addRoute( 164 ..addRoute(
205 name: 'overview', 165 name: 'overview',
206 path: '/overview', 166 path: '/overview',
207 defaultRoute: true, 167 defaultRoute: true,
208 enter: view('book_overview.html')) 168 enter: view('book_overview.html'))
209 ..addRoute( 169 ..addRoute(
210 name: 'read', 170 name: 'read',
211 path: '/read', 171 path: '/read',
212 enter: view('book_read.html')))) 172 enter: view('book_read.html'))))
213 ..addRoute( 173 ..addRoute(
214 name: 'admin', 174 name: 'admin',
215 path: '/admin', 175 path: '/admin',
216 enter: view('admin.html')); 176 enter: view('admin.html'));
217 } 177 }
218 } 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