|
1 | 1 | import { TestBed, async } from '@angular/core/testing'; |
2 | 2 | import { AppComponent } from './app.component'; |
| 3 | +import { HomeComponent } from './components/home/home.component'; |
| 4 | +import { AboutComponent } from './components/about/about.component'; |
| 5 | +import { DashboardComponent } from './components/dashboard/dashboard.component'; |
| 6 | +import { RouterModule } from '@angular/router'; |
| 7 | +import { appRoutes } from "./routerConfig"; |
| 8 | +import { APP_BASE_HREF } from '@angular/common'; |
| 9 | + |
3 | 10 | describe('AppComponent', () => { |
4 | 11 | beforeEach(async(() => { |
5 | 12 | TestBed.configureTestingModule({ |
6 | 13 | declarations: [ |
7 | | - AppComponent |
| 14 | + AppComponent, |
| 15 | + HomeComponent, |
| 16 | + AboutComponent, |
| 17 | + DashboardComponent |
8 | 18 | ], |
| 19 | + imports: [ |
| 20 | + RouterModule.forRoot(appRoutes) |
| 21 | + ], |
| 22 | + providers: [ |
| 23 | + { provide: APP_BASE_HREF, useValue: '/' } |
| 24 | + ] |
9 | 25 | }).compileComponents(); |
10 | 26 | })); |
11 | 27 | it('should create the app', async(() => { |
12 | 28 | const fixture = TestBed.createComponent(AppComponent); |
13 | 29 | const app = fixture.debugElement.componentInstance; |
14 | 30 | expect(app).toBeTruthy(); |
15 | 31 | })); |
16 | | - it(`should have as title 'app'`, async(() => { |
| 32 | + it(`should have as title 'Angular5 Router Sample Application!'`, async(() => { |
17 | 33 | const fixture = TestBed.createComponent(AppComponent); |
18 | 34 | const app = fixture.debugElement.componentInstance; |
19 | | - expect(app.title).toEqual('app'); |
| 35 | + expect(app.title).toEqual('Angular5 Router Sample Application!'); |
20 | 36 | })); |
21 | 37 | it('should render title in a h1 tag', async(() => { |
22 | 38 | const fixture = TestBed.createComponent(AppComponent); |
23 | 39 | fixture.detectChanges(); |
24 | 40 | const compiled = fixture.debugElement.nativeElement; |
25 | | - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); |
| 41 | + expect(compiled.querySelector('h1').textContent).toContain('Angular5 Router Sample Application!'); |
26 | 42 | })); |
27 | 43 | }); |
0 commit comments