11/* tslint:disable:no-unused-variable */
22import { AppComponent } from './app.component' ;
33
4- import { async , inject } from '@angular/core/testing' ;
5-
6- import { TestComponentBuilder } from '@angular/core/testing' ;
4+ import { TestBed } from '@angular/core/testing' ;
75
86import { By } from '@angular/platform-browser' ;
9- import { provide } from '@angular/core' ;
10- import { ViewMetadata } from '@angular/core' ;
117
128//////// SPECS /////////////
139
@@ -19,27 +15,23 @@ describe('Smoke test', () => {
1915} ) ;
2016
2117describe ( 'AppComponent with TCB' , function ( ) {
18+ beforeEach ( ( ) => {
19+ TestBed . configureTestingModule ( { declarations : [ AppComponent ] } ) ;
20+ } ) ;
2221
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+ } ) ;
3626
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 ( ) ;
3830
39- h1 = fixture . debugElement . query ( By . css ( 'h1' ) ) . nativeElement ; // preferred
31+ let h1 = fixture . debugElement . query ( el => el . name === 'h1' ) . nativeElement ; // it works
4032
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
4334
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+ } ) ;
4537} ) ;
0 commit comments