diff --git a/frontend/src/app/app.component.spec.ts b/frontend/src/app/app.component.spec.ts index 0423b7e4..5739cda7 100644 --- a/frontend/src/app/app.component.spec.ts +++ b/frontend/src/app/app.component.spec.ts @@ -25,11 +25,4 @@ describe('AppComponent', () => { const app = fixture.componentInstance; expect(app.title).toEqual('fastenhealth'); }); - - it('should render title', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.nativeElement; - expect(compiled.querySelector('.content span').textContent).toContain('fastenhealth app is running!'); - }); }); diff --git a/frontend/src/app/components/header/header.component.spec.ts b/frontend/src/app/components/header/header.component.spec.ts index 2d0479d7..178d9c23 100644 --- a/frontend/src/app/components/header/header.component.spec.ts +++ b/frontend/src/app/components/header/header.component.spec.ts @@ -1,6 +1,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { HeaderComponent } from './header.component'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; +import {RouterModule} from '@angular/router'; +import {RouterTestingModule} from '@angular/router/testing'; describe('HeaderComponent', () => { let component: HeaderComponent; @@ -8,6 +11,7 @@ describe('HeaderComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ + imports: [ HttpClientTestingModule, RouterTestingModule, RouterModule ], declarations: [ HeaderComponent ] }) .compileComponents(); diff --git a/frontend/src/app/components/resource-list/resource-list.component.spec.ts b/frontend/src/app/components/resource-list/resource-list.component.spec.ts index a288d0e6..81ac8150 100644 --- a/frontend/src/app/components/resource-list/resource-list.component.spec.ts +++ b/frontend/src/app/components/resource-list/resource-list.component.spec.ts @@ -1,6 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ResourceListComponent } from './resource-list.component'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; +import {ResourceListOutletDirective} from './resource-list-outlet.directive'; describe('ResourceListComponent', () => { let component: ResourceListComponent; @@ -8,7 +10,8 @@ describe('ResourceListComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ ResourceListComponent ] + imports: [HttpClientTestingModule], + declarations: [ ResourceListComponent, ResourceListOutletDirective ] }) .compileComponents(); diff --git a/frontend/src/app/pages/auth-signin/auth-signin.component.spec.ts b/frontend/src/app/pages/auth-signin/auth-signin.component.spec.ts index 8d07bbff..97f0b822 100644 --- a/frontend/src/app/pages/auth-signin/auth-signin.component.spec.ts +++ b/frontend/src/app/pages/auth-signin/auth-signin.component.spec.ts @@ -1,6 +1,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { AuthSigninComponent } from './auth-signin.component'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; +import {RouterTestingModule} from '@angular/router/testing'; +import {RouterModule} from '@angular/router'; +import {FormsModule} from '@angular/forms'; describe('AuthSigninComponent', () => { let component: AuthSigninComponent; @@ -8,7 +12,8 @@ describe('AuthSigninComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ AuthSigninComponent ] + declarations: [ AuthSigninComponent ], + imports: [HttpClientTestingModule, FormsModule], }) .compileComponents(); diff --git a/frontend/src/app/pages/auth-signup/auth-signup.component.spec.ts b/frontend/src/app/pages/auth-signup/auth-signup.component.spec.ts index 0d0741a1..73c9d7b1 100644 --- a/frontend/src/app/pages/auth-signup/auth-signup.component.spec.ts +++ b/frontend/src/app/pages/auth-signup/auth-signup.component.spec.ts @@ -1,6 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { AuthSignupComponent } from './auth-signup.component'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; +import {FormsModule} from '@angular/forms'; describe('AuthSignupComponent', () => { let component: AuthSignupComponent; @@ -8,7 +10,8 @@ describe('AuthSignupComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ AuthSignupComponent ] + declarations: [ AuthSignupComponent ], + imports: [HttpClientTestingModule, FormsModule], }) .compileComponents(); diff --git a/frontend/src/app/pages/dashboard/dashboard.component.spec.ts b/frontend/src/app/pages/dashboard/dashboard.component.spec.ts index 9c996c37..18a3f489 100644 --- a/frontend/src/app/pages/dashboard/dashboard.component.spec.ts +++ b/frontend/src/app/pages/dashboard/dashboard.component.spec.ts @@ -1,6 +1,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { DashboardComponent } from './dashboard.component'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; +import {RouterTestingModule} from '@angular/router/testing'; +import {RouterModule} from '@angular/router'; describe('DashboardComponent', () => { let component: DashboardComponent; @@ -8,6 +11,7 @@ describe('DashboardComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ + imports: [HttpClientTestingModule, RouterTestingModule, RouterModule], declarations: [ DashboardComponent ] }) .compileComponents(); diff --git a/frontend/src/app/pages/medical-sources/medical-sources.component.spec.ts b/frontend/src/app/pages/medical-sources/medical-sources.component.spec.ts index fe99f88c..4dbce0d3 100644 --- a/frontend/src/app/pages/medical-sources/medical-sources.component.spec.ts +++ b/frontend/src/app/pages/medical-sources/medical-sources.component.spec.ts @@ -1,6 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MedicalSourcesComponent } from './medical-sources.component'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; +import {RouterTestingModule} from '@angular/router/testing'; describe('MedicalSourcesComponent', () => { let component: MedicalSourcesComponent; @@ -8,7 +10,8 @@ describe('MedicalSourcesComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ MedicalSourcesComponent ] + declarations: [ MedicalSourcesComponent ], + imports: [HttpClientTestingModule, RouterTestingModule], }) .compileComponents(); diff --git a/frontend/src/app/pages/resource-detail/resource-detail.component.spec.ts b/frontend/src/app/pages/resource-detail/resource-detail.component.spec.ts index 94bfa053..ba9a531b 100644 --- a/frontend/src/app/pages/resource-detail/resource-detail.component.spec.ts +++ b/frontend/src/app/pages/resource-detail/resource-detail.component.spec.ts @@ -1,6 +1,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ResourceDetailComponent } from './resource-detail.component'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; +import {RouterTestingModule} from '@angular/router/testing'; +import {ActivatedRoute, convertToParamMap} from '@angular/router'; describe('ResourceDetailComponent', () => { let component: ResourceDetailComponent; @@ -8,7 +11,14 @@ describe('ResourceDetailComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ ResourceDetailComponent ] + declarations: [ ResourceDetailComponent ], + imports: [HttpClientTestingModule, RouterTestingModule], + providers: [ + { + provide: ActivatedRoute, + useValue: {snapshot: {paramMap: convertToParamMap( { 'resource_id': '1234' } )}} + } + ] }) .compileComponents(); diff --git a/frontend/src/app/pages/source-detail/source-detail.component.spec.ts b/frontend/src/app/pages/source-detail/source-detail.component.spec.ts index 96cbebae..13fb9735 100644 --- a/frontend/src/app/pages/source-detail/source-detail.component.spec.ts +++ b/frontend/src/app/pages/source-detail/source-detail.component.spec.ts @@ -1,6 +1,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { SourceDetailComponent } from './source-detail.component'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; +import {RouterTestingModule} from '@angular/router/testing'; +import {ActivatedRoute, convertToParamMap, RouterModule} from '@angular/router'; describe('SourceDetailComponent', () => { let component: SourceDetailComponent; @@ -8,7 +11,14 @@ describe('SourceDetailComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ SourceDetailComponent ] + imports: [HttpClientTestingModule, RouterTestingModule, RouterModule], + declarations: [ SourceDetailComponent ], + providers: [ + { + provide: ActivatedRoute, + useValue: {snapshot: {paramMap: convertToParamMap( { 'source_id': '1234' } )}} + } + ] }) .compileComponents(); diff --git a/frontend/src/app/pages/source-detail/source-detail.component.ts b/frontend/src/app/pages/source-detail/source-detail.component.ts index f0273ef7..c6bac150 100644 --- a/frontend/src/app/pages/source-detail/source-detail.component.ts +++ b/frontend/src/app/pages/source-detail/source-detail.component.ts @@ -22,7 +22,7 @@ export class SourceDetailComponent implements OnInit { constructor(private fastenDb: FastenDbService, private router: Router, private route: ActivatedRoute) { //check if the current Source was sent over using the router state storage: - if(this.router.getCurrentNavigation().extras.state){ + if(this.router.getCurrentNavigation()?.extras?.state){ this.selectedSource = this.router.getCurrentNavigation().extras.state as Source } } diff --git a/frontend/src/app/services/fasten-api.service.spec.ts b/frontend/src/app/services/fasten-api.service.spec.ts index 1883b5df..e0c0add6 100644 --- a/frontend/src/app/services/fasten-api.service.spec.ts +++ b/frontend/src/app/services/fasten-api.service.spec.ts @@ -1,12 +1,16 @@ import { TestBed } from '@angular/core/testing'; import { FastenApiService } from './fasten-api.service'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; + describe('FastenApiService', () => { let service: FastenApiService; beforeEach(() => { - TestBed.configureTestingModule({}); + TestBed.configureTestingModule({ + imports: [ HttpClientTestingModule ], + }); service = TestBed.inject(FastenApiService); }); diff --git a/frontend/src/app/services/fasten-db.service.spec.ts b/frontend/src/app/services/fasten-db.service.spec.ts index 2eecec55..e000a460 100644 --- a/frontend/src/app/services/fasten-db.service.spec.ts +++ b/frontend/src/app/services/fasten-db.service.spec.ts @@ -1,12 +1,15 @@ import { TestBed } from '@angular/core/testing'; import { FastenDbService } from './fasten-db.service'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; describe('FastenDbService', () => { let service: FastenDbService; beforeEach(() => { - TestBed.configureTestingModule({}); + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + }); service = TestBed.inject(FastenDbService); }); diff --git a/frontend/src/app/services/lighthouse.service.spec.ts b/frontend/src/app/services/lighthouse.service.spec.ts index bc29bc55..b54133bf 100644 --- a/frontend/src/app/services/lighthouse.service.spec.ts +++ b/frontend/src/app/services/lighthouse.service.spec.ts @@ -1,12 +1,17 @@ import { TestBed } from '@angular/core/testing'; import { LighthouseService } from './lighthouse.service'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; +import {RouterTestingModule} from '@angular/router/testing'; +import {RouterModule} from '@angular/router'; describe('LighthouseService', () => { let service: LighthouseService; beforeEach(() => { - TestBed.configureTestingModule({}); + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + }); service = TestBed.inject(LighthouseService); });