import { TestBed , async } from '@angular/core/testing' ; import { Component , NgModule , NO_ERRORS_SCHEMA } from '@angular/core' ; import { Router , RouterModule , Routes } from '@angular/router' ; import { RouterTestingModule } from '@angular/router/testing' ; import { AppComponent } from './app.component' ; import { DashboardComponent } from './dashboard/dashboard.component' ; export const routes = [ { path : '' , pathMatch : 'full' , redirectTo : 'dashboard' , } , { path : 'dashboard' , component : DashboardComponent } , { path : '**' , pathMatch : 'full' , redirectTo : 'dashboard' } , ] ; @ Component ( { template : '<div>lazy-loaded</div>' } ) class LazyComponent { } @ NgModule ( { imports : [ RouterModule . forChild ( [ { path : '' , component : LazyComponent } ] ) ] , declarations : [ LazyComponent ] } ) class LazyModule { } describe ( 'AppComponent' , ( ) => { beforeEach ( ( ) => { TestBed . configureTestingModule ( { imports : [ RouterTestingModule . withRoutes ( routes ) ] , declarations : [ AppComponent , DashboardComponent , ] , schemas : [ NO_ERRORS_SCHEMA ] , providers : [ ] , } ) . compileComponents ( ) ; } ) ; it ( 'should create the app' , async ( ( ) => { const fixture = TestBed . createComponent ( AppComponent ) ; const app = fixture . debugElement . componentInstance ; expect ( app ) . toBeTruthy ( ) ; } ) ) ; it ( 'should render title in a ro-nav tag' , async ( ( ) => { const fixture = TestBed . createComponent ( AppComponent ) ; fixture . detectChanges ( ) ; const compiled = fixture . debugElement . nativeElement ; expect ( compiled . querySelector ( 'ro-nav' ) . textContent ) . toBeDefined ( ) ; } ) ) ; it ( 'should render title in a router-outlet tag' , async ( ( ) => { const fixture = TestBed . createComponent ( AppComponent ) ; fixture . detectChanges ( ) ; const compiled = fixture . debugElement . nativeElement ; expect ( compiled . querySelector ( 'router-outlet' ) . textContent ) . toBeDefined ( ) ; } ) ) ; } ) ;