@@ -7,13 +7,15 @@ import {
77 expect ,
88 inject ,
99 beforeEach ,
10- SpyObject
10+ SpyObject ,
11+ IS_DARTIUM
1112} from 'angular2/test_lib' ;
1213
1314import { Promise , PromiseWrapper } from 'angular2/src/facade/async' ;
15+ import { Type } from 'angular2/src/facade/lang' ;
1416
1517import { RouteRegistry } from 'angular2/src/router/route_registry' ;
16- import { RouteConfig , Route , AsyncRoute } from 'angular2/src/router/route_config_decorator' ;
18+ import { RouteConfig , Route , AuxRoute , AsyncRoute } from 'angular2/src/router/route_config_decorator' ;
1719import { stringifyInstruction } from 'angular2/src/router/instruction' ;
1820
1921export function main ( ) {
@@ -185,6 +187,20 @@ export function main() {
185187 . toThrowError ( 'Unexpected "..." before the end of the path for "home/.../fun/".' ) ;
186188 } ) ;
187189
190+
191+ it ( 'should throw if a config has a component that is not defined' , ( ) => {
192+ expect ( ( ) => registry . config ( RootHostCmp , new Route ( { path : '/' , component : null } ) ) )
193+ . toThrowError ( 'Component for route "/" is not defined, or is not a class.' ) ;
194+ expect ( ( ) => registry . config ( RootHostCmp , new AuxRoute ( { path : '/' , component : null } ) ) )
195+ . toThrowError ( 'Component for route "/" is not defined, or is not a class.' ) ;
196+
197+ // This would never happen in Dart
198+ if ( ! IS_DARTIUM ) {
199+ expect ( ( ) => registry . config ( RootHostCmp , new Route ( { path : '/' , component :< Type > ( < any > 4 ) } ) ) )
200+ . toThrowError ( 'Component for route "/" is not defined, or is not a class.' ) ;
201+ }
202+ } ) ;
203+
188204 it ( 'should match matrix params on child components and query params on the root component' ,
189205 inject ( [ AsyncTestCompleter ] , ( async ) => {
190206 registry . config ( RootHostCmp , new Route ( { path : '/first/...' , component : DummyParentCmp } ) ) ;
0 commit comments