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

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

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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
(Empty)
1 library ng_bind_route_spec;
2
3 import 'dart:html';
4 import '../_specs.dart';
5 import 'package:angular/routing/module.dart';
6 import 'package:angular/mock/module.dart';
7
8 main() {
9 describe('ngBindRoute', () {
10 TestBed _;
11
12 beforeEach(module((Module m) => m
13 ..install(new AngularMockModule())
14 ..type(RouteInitializer, implementedBy: NestedRouteInitializer)));
15
16 beforeEach(inject((TestBed tb) {
17 _ = tb;
18 }));
19
20
21 it('should inject null RouteProvider when no ng-bind-route', async(() {
22 Element root = _.compile('<div probe="routeProbe"></div>');
23 expect(_.rootScope['routeProbe'].injector.get(RouteProvider)).toBeNull();
24 }));
25
26
27 it('should inject RouteProvider with correct flat route', async(() {
28 Element root = _.compile(
29 '<div ng-bind-route="library"><div probe="routeProbe"></div></div>');
30 expect(_.rootScope['routeProbe'].injector.get(RouteProvider).routeName)
31 .toEqual('library');
32 }));
33
34
35 it('should inject RouteProvider with correct nested route', async(() {
36 Element root = _.compile(
37 '<div ng-bind-route="library">'
38 ' <div ng-bind-route=".all">'
39 ' <div probe="routeProbe"></div>'
40 ' </div>'
41 '</div>');
42 expect(_.rootScope['routeProbe'].injector.get(RouteProvider).route.name)
43 .toEqual('all');
44 }));
45
46 });
47 }
48
49 class NestedRouteInitializer implements RouteInitializer {
50 void init(Router router, ViewFactory view) {
51 router.root
52 ..addRoute(
53 name: 'library',
54 path: '/library',
55 enter: view('library.html'),
56 mount: (Route route) => route
57 ..addRoute(
58 name: 'all',
59 path: '/all',
60 enter: view('book_list.html'))
61 ..addRoute(
62 name: 'book',
63 path: '/:bookId',
64 mount: (Route route) => route
65 ..addRoute(
66 name: 'overview',
67 path: '/overview',
68 defaultRoute: true,
69 enter: view('book_overview.html'))
70 ..addRoute(
71 name: 'read',
72 path: '/read',
73 enter: view('book_read.html'))))
74 ..addRoute(
75 name: 'admin',
76 path: '/admin',
77 enter: view('admin.html'));
78 }
79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698