1 import { TestBed, async } from '@angular/core/testing';
2 import { AppComponent } from './app.component';
3 import { Component } from '@angular/core';
5 @Component({selector: 'router-outlet', template: ''})
6 class RouterOutletStubComponent { }
8 @Component({selector: 'app-messages', template: ''})
9 class MessagesStubComponent {}
11 describe('AppComponent', () => {
12 beforeEach(async(() => {
13 TestBed.configureTestingModule({
16 RouterOutletStubComponent,
19 }).compileComponents();
22 it('should create the app', () => {
23 const fixture = TestBed.createComponent(AppComponent);
24 const app = fixture.debugElement.componentInstance;
25 expect(app).toBeTruthy();
28 it(`should have as title 'Tour of Heroes'`, () => {
29 const fixture = TestBed.createComponent(AppComponent);
30 const app = fixture.debugElement.componentInstance;
31 expect(app.title).toEqual('Tour of Heroes');
34 it(`should render the title 'Tour of Heroes'`, () => {
35 const fixture = TestBed.createComponent(AppComponent);
36 fixture.detectChanges();
37 const compiled = fixture.debugElement.nativeElement;
38 expect(compiled.querySelector('h1').textContent).toContain('Tour of Heroes');
41 it(`should render the link 'Heroes'`, () => {
42 const fixture = TestBed.createComponent(AppComponent);
43 fixture.detectChanges();
44 const compiled = fixture.debugElement.nativeElement;
45 expect(compiled.querySelector('nav > a:nth-child(1)').textContent).toContain('Dashboard');
46 expect(compiled.querySelector('nav > a:nth-child(2)').textContent).toContain('Heroes');