Skip to content

Commit c246f56

Browse files
committed
Move http controller into test method
1 parent c74dc4a commit c246f56

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

package-lock.json

+7-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"karma-coverage": "~2.0.3",
3636
"karma-jasmine": "~4.0.0",
3737
"karma-jasmine-html-reporter": "~1.7.0",
38+
"path-parse": "~1.0.7",
3839
"puppeteer": "^13.0.0",
3940
"tslint": "^6.1.3",
4041
"typescript": "~4.4.3"

src/app/app.component.spec.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import { TestBed } from '@angular/core/testing';
22
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
3-
import { HttpClient } from '@angular/common/http';
43
import { AppComponent } from './app.component';
54

65
describe('AppComponent', () => {
7-
let httpClient: HttpClient;
8-
let httpTestingController: HttpTestingController;
96

107
beforeEach(async () => {
118
await TestBed.configureTestingModule({
@@ -14,8 +11,6 @@ describe('AppComponent', () => {
1411
],
1512
imports: [HttpClientTestingModule]
1613
}).compileComponents();
17-
httpClient = TestBed.inject(HttpClient);
18-
httpTestingController = TestBed.inject(HttpTestingController);
1914
});
2015

2116
it('should create the app', () => {
@@ -32,7 +27,7 @@ describe('AppComponent', () => {
3227

3328
it('should render title', () => {
3429
const fixture = TestBed.createComponent(AppComponent);
35-
const req = httpTestingController.expectOne('resource');
30+
const req = TestBed.inject(HttpTestingController).expectOne('resource');
3631
expect(req.request.method).toEqual('GET');
3732
req.flush({ "id": "1234", "content": "Hello" });
3833
fixture.whenRenderingDone().then(

0 commit comments

Comments
 (0)