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

Unified Diff: third_party/pkg/angular/test/routing/ng_view_spec.dart

Issue 257423008: 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 side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/test/routing/ng_view_spec.dart
diff --git a/third_party/pkg/angular/test/routing/ng_view_spec.dart b/third_party/pkg/angular/test/routing/ng_view_spec.dart
index 99edd1d4f0e26211b45921721f4d98890262d686..c8f6968db7c77c10c86f3f77e0655e0fa8fb7f32 100644
--- a/third_party/pkg/angular/test/routing/ng_view_spec.dart
+++ b/third_party/pkg/angular/test/routing/ng_view_spec.dart
@@ -10,13 +10,13 @@ main() {
TestBed _;
Router router;
- beforeEach(module((Module m) {
- m
+ beforeEachModule((Module module) {
+ module
..install(new AngularMockModule())
..type(RouteInitializerFn, implementedBy: FlatRouteInitializer);
- }));
+ });
- beforeEach(inject((TestBed tb, Router _router, TemplateCache templates) {
+ beforeEach((TestBed tb, Router _router, TemplateCache templates) {
_ = tb;
router = _router;
@@ -24,52 +24,57 @@ main() {
'<h1>Foo</h1>'));
templates.put('bar.html', new HttpResponse(200,
'<h1>Bar</h1>'));
- }));
+ });
it('should switch template', async(() {
- Element root = _.compile('<ng-view></ng-view>');
+ Element root = _.compile('<div><ng-view></ng-view></div>');
expect(root.text).toEqual('');
router.route('/foo');
microLeap();
+ _.rootScope.apply();
expect(root.text).toEqual('Foo');
router.route('/bar');
microLeap();
+ _.rootScope.apply();
expect(root.text).toEqual('Bar');
router.route('/foo');
microLeap();
+ _.rootScope.apply();
expect(root.text).toEqual('Foo');
}));
it('should switch template when route is already active', async(() {
// Force the routing system to initialize.
- _.compile('<ng-view></ng-view>');
+ _.compile('<div><ng-view></ng-view></div>');
router.route('/foo');
microLeap();
- Element root = _.compile('<ng-view></ng-view>');
+ Element root = _.compile('<div><ng-view></ng-view></div>');
expect(root.text).toEqual('');
- _.rootScope.apply();
microLeap();
+ _.rootScope.apply();
expect(root.text).toEqual('Foo');
}));
it('should clear template when route is deactivated', async(() {
- Element root = _.compile('<ng-view></ng-view>');
+ Element root = _.compile('<div><ng-view></ng-view></div>');
expect(root.text).toEqual('');
router.route('/foo');
microLeap();
+ _.rootScope.apply();
expect(root.text).toEqual('Foo');
router.route('/baz'); // route without a template
microLeap();
+ _.rootScope.apply();
expect(root.text).toEqual('');
}));
@@ -80,13 +85,13 @@ main() {
TestBed _;
Router router;
- beforeEach(module((Module m) {
- m
+ beforeEachModule((Module module) {
+ module
..install(new AngularMockModule())
..type(RouteInitializerFn, implementedBy: NestedRouteInitializer);
- }));
+ });
- beforeEach(inject((TestBed tb, Router _router, TemplateCache templates) {
+ beforeEach((TestBed tb, Router _router, TemplateCache templates) {
_ = tb;
router = _router;
@@ -99,37 +104,72 @@ main() {
'<h2>Book 1234</h2>'));
templates.put('book_read.html', new HttpResponse(200,
'<h2>Read Book 1234</h2>'));
- }));
-
+ });
it('should switch nested templates', async(() {
- Element root = _.compile('<ng-view></ng-view>');
+ Element root = _.compile('<div><ng-view></ng-view></div>');
expect(root.text).toEqual('');
router.route('/library/all');
microLeap();
+ _.rootScope.apply();
expect(root.text).toEqual('LibraryBooks');
router.route('/library/1234');
microLeap();
+ _.rootScope.apply();
expect(root.text).toEqual('LibraryBook 1234');
// nothing should change here
router.route('/library/1234/overview');
microLeap();
+ _.rootScope.apply();
expect(root.text).toEqual('LibraryBook 1234');
// nothing should change here
router.route('/library/1234/read');
microLeap();
+ _.rootScope.apply();
expect(root.text).toEqual('LibraryRead Book 1234');
}));
+ });
+
+
+ describe('Inline template ngView', () {
+ TestBed _;
+ Router router;
+ beforeEachModule((Module module) {
+ module
+ ..install(new AngularMockModule())
+ ..value(RouteInitializerFn, (router, views) {
+ views.configure({
+ 'foo': ngRoute(
+ path: '/foo',
+ viewHtml: '<h1>Hello</h1>')
+ });
+ });
+ });
+
+ beforeEach((TestBed tb, Router _router, TemplateCache templates) {
+ _ = tb;
+ router = _router;
+ });
+
+ it('should switch inline templates', async(() {
+ Element root = _.compile('<div><ng-view></ng-view></div>');
+ expect(root.text).toEqual('');
+
+ router.route('/foo');
+ microLeap();
+ _.rootScope.apply();
+ expect(root.text).toEqual('Hello');
+ }));
});
}
class FlatRouteInitializer implements Function {
- void call(Router router, ViewFactory view) {
+ void call(Router router, RouteViewFactory view) {
router.root
..addRoute(
name: 'foo',
@@ -146,7 +186,7 @@ class FlatRouteInitializer implements Function {
}
class NestedRouteInitializer implements Function {
- void call(Router router, ViewFactory view) {
+ void call(Router router, RouteViewFactory view) {
router.root
..addRoute(
name: 'library',
« 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