1
1
/* tslint:disable:no-unused-variable */
2
2
import { AppComponent } from './app.component' ;
3
3
4
- import { async , inject } from '@angular/core/testing' ;
5
-
6
- import { TestComponentBuilder } from '@angular/core/testing' ;
4
+ import { TestBed } from '@angular/core/testing' ;
7
5
8
6
import { By } from '@angular/platform-browser' ;
9
- import { provide } from '@angular/core' ;
10
- import { ViewMetadata } from '@angular/core' ;
11
7
12
8
//////// SPECS /////////////
13
9
@@ -19,27 +15,23 @@ describe('Smoke test', () => {
19
15
} ) ;
20
16
21
17
describe ( 'AppComponent with TCB' , function ( ) {
18
+ beforeEach ( ( ) => {
19
+ TestBed . configureTestingModule ( { declarations : [ AppComponent ] } ) ;
20
+ } ) ;
22
21
23
- it ( 'should instantiate component' ,
24
- async ( inject ( [ TestComponentBuilder ] , ( tcb : TestComponentBuilder ) => {
25
-
26
- tcb . createAsync ( AppComponent ) . then ( fixture => {
27
- expect ( fixture . componentInstance instanceof AppComponent ) . toBe ( true , 'should create AppComponent' ) ;
28
- } ) ;
29
- } ) ) ) ;
30
-
31
- it ( 'should have expected <h1> text' ,
32
- async ( inject ( [ TestComponentBuilder ] , ( tcb : TestComponentBuilder ) => {
33
-
34
- tcb . createAsync ( AppComponent ) . then ( fixture => {
35
- // fixture.detectChanges(); // would need to resolve a binding but we don't have a binding
22
+ it ( 'should instantiate component' , ( ) => {
23
+ let fixture = TestBed . createComponent ( AppComponent ) ;
24
+ expect ( fixture . componentInstance instanceof AppComponent ) . toBe ( true , 'should create AppComponent' ) ;
25
+ } ) ;
36
26
37
- let h1 = fixture . debugElement . query ( el => el . name === 'h1' ) . nativeElement ; // it works
27
+ it ( 'should have expected <h1> text' , ( ) => {
28
+ let fixture = TestBed . createComponent ( AppComponent ) ;
29
+ fixture . detectChanges ( ) ;
38
30
39
- h1 = fixture . debugElement . query ( By . css ( 'h1' ) ) . nativeElement ; // preferred
31
+ let h1 = fixture . debugElement . query ( el => el . name === 'h1' ) . nativeElement ; // it works
40
32
41
- expect ( h1 . innerText ) . toMatch ( / a n g u l a r 2 a p p / i, '<h1> should say something about "Angular 2 App"' ) ;
42
- } ) ;
33
+ h1 = fixture . debugElement . query ( By . css ( 'h1' ) ) . nativeElement ; // preferred
43
34
44
- } ) ) ) ;
35
+ expect ( h1 . innerText ) . toMatch ( / a n g u l a r 2 a p p / i, '<h1> should say something about "Angular 2 App"' ) ;
36
+ } ) ;
45
37
} ) ;
0 commit comments