fix(router): throw when component in route config is not defined

Close #3265

Closes #3569
This commit is contained in:
Brian Ford
2015-08-10 13:05:08 -07:00
parent f83289b1a0
commit 903a0f0513
3 changed files with 41 additions and 3 deletions
@@ -16,6 +16,7 @@ import {Component, Directive, View} from 'angular2/annotations';
import {DOM} from 'angular2/src/dom/dom_adapter';
import {bind} from 'angular2/di';
import {DOCUMENT_TOKEN} from 'angular2/src/render/render';
import {Type} from 'angular2/src/facade/lang';
import {
routerInjectables,
@@ -7,13 +7,15 @@ import {
expect,
inject,
beforeEach,
SpyObject
SpyObject,
IS_DARTIUM
} from 'angular2/test_lib';
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
import {Type} from 'angular2/src/facade/lang';
import {RouteRegistry} from 'angular2/src/router/route_registry';
import {RouteConfig, Route, AsyncRoute} from 'angular2/src/router/route_config_decorator';
import {RouteConfig, Route, AuxRoute, AsyncRoute} from 'angular2/src/router/route_config_decorator';
import {stringifyInstruction} from 'angular2/src/router/instruction';
export function main() {
@@ -185,6 +187,20 @@ export function main() {
.toThrowError('Unexpected "..." before the end of the path for "home/.../fun/".');
});
it('should throw if a config has a component that is not defined', () => {
expect(() => registry.config(RootHostCmp, new Route({path: '/', component: null})))
.toThrowError('Component for route "/" is not defined, or is not a class.');
expect(() => registry.config(RootHostCmp, new AuxRoute({path: '/', component: null})))
.toThrowError('Component for route "/" is not defined, or is not a class.');
// This would never happen in Dart
if (!IS_DARTIUM) {
expect(() => registry.config(RootHostCmp, new Route({path: '/', component:<Type>(<any>4)})))
.toThrowError('Component for route "/" is not defined, or is not a class.');
}
});
it('should match matrix params on child components and query params on the root component',
inject([AsyncTestCompleter], (async) => {
registry.config(RootHostCmp, new Route({path: '/first/...', component: DummyParentCmp}));