diff --git a/aio/content/examples/http/specs.stackblitz.json b/aio/content/examples/http/specs.stackblitz.json index 1442c98f3a..68c0874f18 100644 --- a/aio/content/examples/http/specs.stackblitz.json +++ b/aio/content/examples/http/specs.stackblitz.json @@ -1,6 +1,7 @@ { "description": "Http Guide Testing", "files":[ + "src/app/heroes/hero.ts", "src/app/heroes/heroes.service.ts", "src/app/heroes/heroes.service.spec.ts", diff --git a/aio/content/examples/http/src/app/heroes/heroes.service.spec.ts b/aio/content/examples/http/src/app/heroes/heroes.service.spec.ts index c3bf9bc7e0..bfc204b4ad 100644 --- a/aio/content/examples/http/src/app/heroes/heroes.service.spec.ts +++ b/aio/content/examples/http/src/app/heroes/heroes.service.spec.ts @@ -28,9 +28,9 @@ describe('HeroesService', () => { // Inject the http, test controller, and service-under-test // as they will be referenced by each test. - httpClient = TestBed.inject(HttpClient); - httpTestingController = TestBed.inject(HttpTestingController); - heroService = TestBed.inject(HeroesService); + httpClient = TestBed.get(HttpClient); + httpTestingController = TestBed.get(HttpTestingController); + heroService = TestBed.get(HeroesService); }); afterEach(() => { @@ -44,7 +44,7 @@ describe('HeroesService', () => { let expectedHeroes: Hero[]; beforeEach(() => { - heroService = TestBed.inject(HeroesService); + heroService = TestBed.get(HeroesService); expectedHeroes = [ { id: 1, name: 'A' }, { id: 2, name: 'B' }, diff --git a/aio/content/examples/http/src/main.ts b/aio/content/examples/http/src/main.ts index 6b6532d428..0740658908 100644 --- a/aio/content/examples/http/src/main.ts +++ b/aio/content/examples/http/src/main.ts @@ -1,5 +1,12 @@ // #docregion +import { enableProdMode } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + import { AppModule } from './app/app.module'; +import { environment } from './environments/environment'; + +if (environment.production) { + enableProdMode(); +} platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/aio/content/examples/http/src/testing/http-client.spec.ts b/aio/content/examples/http/src/testing/http-client.spec.ts index d098397e79..f13c15a18b 100644 --- a/aio/content/examples/http/src/testing/http-client.spec.ts +++ b/aio/content/examples/http/src/testing/http-client.spec.ts @@ -27,8 +27,8 @@ describe('HttpClient testing', () => { }); // Inject the http service and test controller for each test - httpClient = TestBed.inject(HttpClient); - httpTestingController = TestBed.inject(HttpTestingController); + httpClient = TestBed.get(HttpClient); + httpTestingController = TestBed.get(HttpTestingController); }); // #enddocregion setup // #docregion afterEach @@ -67,6 +67,7 @@ describe('HttpClient testing', () => { httpTestingController.verify(); }); // #enddocregion get-test + it('can test HttpClient.get with matching header', () => { const testData: Data = {name: 'Test Data'}; diff --git a/aio/content/examples/http/stackblitz.json b/aio/content/examples/http/stackblitz.json index 6ef625c1a0..5d24738b29 100644 --- a/aio/content/examples/http/stackblitz.json +++ b/aio/content/examples/http/stackblitz.json @@ -5,7 +5,8 @@ "!**/*.js", "!src/testing/*.*", - "!src/index-specs.html" + "!src/index-specs.html", + "!src/main-specs.ts" ], "tags": ["http"] }