| Index: third_party/pkg/angular/test/routing/ng_bind_route_spec.dart
|
| diff --git a/third_party/pkg/angular/test/routing/ng_bind_route_spec.dart b/third_party/pkg/angular/test/routing/ng_bind_route_spec.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..827b99f96957645fcb5796b4648d8a6dc4cfcfab
|
| --- /dev/null
|
| +++ b/third_party/pkg/angular/test/routing/ng_bind_route_spec.dart
|
| @@ -0,0 +1,79 @@
|
| +library ng_bind_route_spec;
|
| +
|
| +import 'dart:html';
|
| +import '../_specs.dart';
|
| +import 'package:angular/routing/module.dart';
|
| +import 'package:angular/mock/module.dart';
|
| +
|
| +main() {
|
| + describe('ngBindRoute', () {
|
| + TestBed _;
|
| +
|
| + beforeEach(module((Module m) => m
|
| + ..install(new AngularMockModule())
|
| + ..type(RouteInitializer, implementedBy: NestedRouteInitializer)));
|
| +
|
| + beforeEach(inject((TestBed tb) {
|
| + _ = tb;
|
| + }));
|
| +
|
| +
|
| + it('should inject null RouteProvider when no ng-bind-route', async(() {
|
| + Element root = _.compile('<div probe="routeProbe"></div>');
|
| + expect(_.rootScope['routeProbe'].injector.get(RouteProvider)).toBeNull();
|
| + }));
|
| +
|
| +
|
| + it('should inject RouteProvider with correct flat route', async(() {
|
| + Element root = _.compile(
|
| + '<div ng-bind-route="library"><div probe="routeProbe"></div></div>');
|
| + expect(_.rootScope['routeProbe'].injector.get(RouteProvider).routeName)
|
| + .toEqual('library');
|
| + }));
|
| +
|
| +
|
| + it('should inject RouteProvider with correct nested route', async(() {
|
| + Element root = _.compile(
|
| + '<div ng-bind-route="library">'
|
| + ' <div ng-bind-route=".all">'
|
| + ' <div probe="routeProbe"></div>'
|
| + ' </div>'
|
| + '</div>');
|
| + expect(_.rootScope['routeProbe'].injector.get(RouteProvider).route.name)
|
| + .toEqual('all');
|
| + }));
|
| +
|
| + });
|
| +}
|
| +
|
| +class NestedRouteInitializer implements RouteInitializer {
|
| + void init(Router router, ViewFactory view) {
|
| + router.root
|
| + ..addRoute(
|
| + name: 'library',
|
| + path: '/library',
|
| + enter: view('library.html'),
|
| + mount: (Route route) => route
|
| + ..addRoute(
|
| + name: 'all',
|
| + path: '/all',
|
| + enter: view('book_list.html'))
|
| + ..addRoute(
|
| + name: 'book',
|
| + path: '/:bookId',
|
| + mount: (Route route) => route
|
| + ..addRoute(
|
| + name: 'overview',
|
| + path: '/overview',
|
| + defaultRoute: true,
|
| + enter: view('book_overview.html'))
|
| + ..addRoute(
|
| + name: 'read',
|
| + path: '/read',
|
| + enter: view('book_read.html'))))
|
| + ..addRoute(
|
| + name: 'admin',
|
| + path: '/admin',
|
| + enter: view('admin.html'));
|
| + }
|
| +}
|
|
|