1
|
import { TestBed, async } from '@angular/core/testing';
|
2
|
|
3
|
import { AppComponent } from './app.component';
|
4
|
|
5
|
describe('AppComponent', () => {
|
6
|
beforeEach(async(() => {
|
7
|
TestBed.configureTestingModule({
|
8
|
declarations: [
|
9
|
AppComponent
|
10
|
],
|
11
|
}).compileComponents();
|
12
|
}));
|
13
|
|
14
|
it('should create the app', async(() => {
|
15
|
const fixture = TestBed.createComponent(AppComponent);
|
16
|
const app = fixture.debugElement.componentInstance;
|
17
|
expect(app).toBeTruthy();
|
18
|
}));
|
19
|
|
20
|
it(`should have as title 'app'`, async(() => {
|
21
|
const fixture = TestBed.createComponent(AppComponent);
|
22
|
const app = fixture.debugElement.componentInstance;
|
23
|
expect(app.title).toEqual('app');
|
24
|
}));
|
25
|
|
26
|
it('should render title in a h1 tag', async(() => {
|
27
|
const fixture = TestBed.createComponent(AppComponent);
|
28
|
fixture.detectChanges();
|
29
|
const compiled = fixture.debugElement.nativeElement;
|
30
|
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
|
31
|
}));
|
32
|
});
|