|
15 | 15 | import { TestBed, waitForAsync } from "@angular/core/testing"; |
16 | 16 | import { RouterTestingModule } from "@angular/router/testing"; |
17 | 17 | import { AppComponent } from "./app.component"; |
| 18 | +import { provideHttpClient, withInterceptorsFromDi } from "@angular/common/http"; |
| 19 | + |
18 | 20 | describe("AppComponent", () => { |
19 | | - // beforeEach(async(() => { |
20 | | - // TestBed.configureTestingModule({ |
21 | | - // imports: [ |
22 | | - // RouterTestingModule |
23 | | - // ], |
24 | | - // declarations: [ |
25 | | - // AppComponent |
26 | | - // ], |
27 | | - // }).compileComponents(); |
28 | | - // })); |
29 | | - // it('should create the app', async(() => { |
30 | | - // const fixture = TestBed.createComponent(AppComponent); |
31 | | - // const app = fixture.debugElement.componentInstance; |
32 | | - // expect(app).toBeTruthy(); |
33 | | - // })); |
34 | | - // it(`should have as title 'app'`, async(() => { |
35 | | - // const fixture = TestBed.createComponent(AppComponent); |
36 | | - // const app = fixture.debugElement.componentInstance; |
37 | | - // expect(app.title).toEqual('app'); |
38 | | - // })); |
39 | | - // it('should render title in a h1 tag', async(() => { |
40 | | - // const fixture = TestBed.createComponent(AppComponent); |
41 | | - // fixture.detectChanges(); |
42 | | - // const compiled = fixture.debugElement.nativeElement; |
43 | | - // expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); |
44 | | - // })); |
45 | | - it("should calc correctly", () => { |
46 | | - expect(1 + 1).toEqual(2); |
47 | | - }); |
| 21 | + beforeEach(waitForAsync(() => { |
| 22 | + TestBed.configureTestingModule({ |
| 23 | + imports: [RouterTestingModule,AppComponent], |
| 24 | + providers: [provideHttpClient(withInterceptorsFromDi())] |
| 25 | +}).compileComponents(); |
| 26 | + })); |
| 27 | + it("should create the app", waitForAsync(() => { |
| 28 | + const fixture = TestBed.createComponent(AppComponent); |
| 29 | + const app = fixture.debugElement.componentInstance; |
| 30 | + expect(app).toBeTruthy(); |
| 31 | + })); |
| 32 | + it(`should have as title 'app'`, waitForAsync(() => { |
| 33 | + const fixture = TestBed.createComponent(AppComponent); |
| 34 | + const app = fixture.debugElement.componentInstance; |
| 35 | + expect(app.title).toEqual("app"); |
| 36 | + })); |
48 | 37 | }); |
0 commit comments