import { TestComponentBuilder , describe , expect , injectAsync , it , beforeEachProviders } from 'angular2/testing' ; import { Component , provide , DirectiveResolver } from 'angular2/core' ; import { Location , Router , RouteRegistry , ROUTER_PRIMARY_COMPONENT } from 'angular2/router' ; import { SpyLocation } from 'angular2/src/mock/location_mock' ; import { RootRouter } from 'angular2/src/router/router' ; import { DOM } from 'angular2/src/platform/dom/dom_adapter' ; import { AppCmp } from './app' ; export function main ( ) { describe ( 'App component' , ( ) => { beforeEachProviders ( ( ) => [ RouteRegistry , DirectiveResolver , provide ( Location , { useClass : SpyLocation } ) , provide ( ROUTER_PRIMARY_COMPONENT , { useValue : AppCmp } ) , provide ( Router , { useClass : RootRouter } ) ] ) ; it ( 'should work' , injectAsync ( [ TestComponentBuilder ] , ( tcb ) => { return tcb . createAsync ( TestComponent ) . then ( rootTC => { rootTC . detectChanges ( ) ; let appDOMEl = rootTC . debugElement . componentViewChildren [ 0 ] . nativeElement ; expect ( DOM . querySelectorAll ( appDOMEl , 'section > nav > a' ) [ 1 ] . href ) . toMatch ( /http:\/\/localhost:\d+\/about/ ) ; } ) ; } ) ) ; } ) ; } @ Component ( { selector : 'test-cmp' , template : '<div><app></app></div>' , directives : [ AppCmp ] } ) class TestComponent { }