1
1
import { TestBed } from '@angular/core/testing' ;
2
2
import { HttpClientTestingModule , HttpTestingController } from '@angular/common/http/testing' ;
3
- import { HttpClient } from '@angular/common/http' ;
4
3
import { AppComponent } from './app.component' ;
5
4
6
5
describe ( 'AppComponent' , ( ) => {
7
- let httpClient : HttpClient ;
8
- let httpTestingController : HttpTestingController ;
9
6
10
7
beforeEach ( async ( ) => {
11
8
await TestBed . configureTestingModule ( {
@@ -14,8 +11,6 @@ describe('AppComponent', () => {
14
11
] ,
15
12
imports : [ HttpClientTestingModule ]
16
13
} ) . compileComponents ( ) ;
17
- httpClient = TestBed . inject ( HttpClient ) ;
18
- httpTestingController = TestBed . inject ( HttpTestingController ) ;
19
14
} ) ;
20
15
21
16
it ( 'should create the app' , ( ) => {
@@ -32,7 +27,7 @@ describe('AppComponent', () => {
32
27
33
28
it ( 'should render title' , ( ) => {
34
29
const fixture = TestBed . createComponent ( AppComponent ) ;
35
- const req = httpTestingController . expectOne ( 'resource' ) ;
30
+ const req = TestBed . inject ( HttpTestingController ) . expectOne ( 'resource' ) ;
36
31
expect ( req . request . method ) . toEqual ( 'GET' ) ;
37
32
req . flush ( { "id" : "1234" , "content" : "Hello" } ) ;
38
33
fixture . whenRenderingDone ( ) . then (
0 commit comments