diff --git a/frontend/src/app/components/medical-sources-card/medical-sources-card.component.ts b/frontend/src/app/components/medical-sources-card/medical-sources-card.component.ts index 740774ae..aaf15792 100644 --- a/frontend/src/app/components/medical-sources-card/medical-sources-card.component.ts +++ b/frontend/src/app/components/medical-sources-card/medical-sources-card.component.ts @@ -24,6 +24,7 @@ export class MedicalSourcesCardComponent implements OnInit { } getSourceDisplayName(sourceItem: SourceListItem): string { + if(!sourceItem) return "Unknown" if(sourceItem.metadata?.display) { return sourceItem.metadata?.display } diff --git a/frontend/src/app/pages/background-jobs/background-jobs.component.spec.ts b/frontend/src/app/pages/background-jobs/background-jobs.component.spec.ts index 15fbcadc..569551d0 100644 --- a/frontend/src/app/pages/background-jobs/background-jobs.component.spec.ts +++ b/frontend/src/app/pages/background-jobs/background-jobs.component.spec.ts @@ -1,6 +1,11 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { BackgroundJobsComponent } from './background-jobs.component'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; +import {RouterTestingModule} from '@angular/router/testing'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {HTTP_CLIENT_TOKEN} from '../../dependency-injection'; +import {HttpClient} from '@angular/common/http'; describe('BackgroundJobsComponent', () => { let component: BackgroundJobsComponent; @@ -8,7 +13,14 @@ describe('BackgroundJobsComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ BackgroundJobsComponent ] + declarations: [ BackgroundJobsComponent ], + imports: [HttpClientTestingModule], + providers: [ + { + provide: HTTP_CLIENT_TOKEN, + useClass: HttpClient, + }, + ] }) .compileComponents(); diff --git a/frontend/src/app/pages/report-labs/report-labs.component.spec.ts b/frontend/src/app/pages/report-labs/report-labs.component.spec.ts index 5d020bed..1eb3fbc5 100644 --- a/frontend/src/app/pages/report-labs/report-labs.component.spec.ts +++ b/frontend/src/app/pages/report-labs/report-labs.component.spec.ts @@ -4,6 +4,7 @@ import { ReportLabsComponent } from './report-labs.component'; import {FastenApiService} from '../../services/fasten-api.service'; import {NgbModalModule} from '@ng-bootstrap/ng-bootstrap'; import {of} from 'rxjs'; +import {RouterTestingModule} from '@angular/router/testing'; describe('ReportLabsComponent', () => { let component: ReportLabsComponent; @@ -12,9 +13,10 @@ describe('ReportLabsComponent', () => { beforeEach(async () => { - mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResources']) + mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResources', 'queryResources']) await TestBed.configureTestingModule({ declarations: [ ReportLabsComponent ], + imports: [RouterTestingModule], providers: [{ provide: FastenApiService, useValue: mockedFastenApiService @@ -22,6 +24,7 @@ describe('ReportLabsComponent', () => { }) .compileComponents(); mockedFastenApiService.getResources.and.returnValue(of([])); + mockedFastenApiService.queryResources.and.returnValue(of([])); fixture = TestBed.createComponent(ReportLabsComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/services/event-bus.service.spec.ts b/frontend/src/app/services/event-bus.service.spec.ts index 574fc894..3c2d2840 100644 --- a/frontend/src/app/services/event-bus.service.spec.ts +++ b/frontend/src/app/services/event-bus.service.spec.ts @@ -1,12 +1,23 @@ import { TestBed } from '@angular/core/testing'; import { EventBusService } from './event-bus.service'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; +import {HTTP_CLIENT_TOKEN} from '../dependency-injection'; +import {HttpClient} from '@angular/common/http'; describe('EventBusService', () => { let service: EventBusService; beforeEach(() => { - TestBed.configureTestingModule({}); + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [ + { + provide: HTTP_CLIENT_TOKEN, + useClass: HttpClient, + }, + ] + }); service = TestBed.inject(EventBusService); }); diff --git a/frontend/src/app/widgets/image-list-group-widget/image-list-group-widget.component.spec.ts b/frontend/src/app/widgets/image-list-group-widget/image-list-group-widget.component.spec.ts index e385d67e..a6da37f7 100644 --- a/frontend/src/app/widgets/image-list-group-widget/image-list-group-widget.component.spec.ts +++ b/frontend/src/app/widgets/image-list-group-widget/image-list-group-widget.component.spec.ts @@ -1,6 +1,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ImageListGroupWidgetComponent } from './image-list-group-widget.component'; +import {FastenApiService} from '../../services/fasten-api.service'; +import {HTTP_CLIENT_TOKEN} from '../../dependency-injection'; +import {HttpClient} from '@angular/common/http'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; describe('ImageListGroupWidgetComponent', () => { let component: ImageListGroupWidgetComponent; @@ -8,7 +12,13 @@ describe('ImageListGroupWidgetComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ ImageListGroupWidgetComponent ] + imports: [ ImageListGroupWidgetComponent, HttpClientTestingModule ], + providers: [ + { + provide: HTTP_CLIENT_TOKEN, + useClass: HttpClient, + }, + ] }) .compileComponents(); diff --git a/frontend/src/app/widgets/patient-vitals-widget/patient-vitals-widget.component.spec.ts b/frontend/src/app/widgets/patient-vitals-widget/patient-vitals-widget.component.spec.ts index ab2ce198..b29975cd 100644 --- a/frontend/src/app/widgets/patient-vitals-widget/patient-vitals-widget.component.spec.ts +++ b/frontend/src/app/widgets/patient-vitals-widget/patient-vitals-widget.component.spec.ts @@ -16,7 +16,6 @@ describe('PatientVitalsWidgetComponent', () => { beforeEach(async () => { mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['queryResources']) - await TestBed.configureTestingModule({ imports: [ PatientVitalsWidgetComponent, RouterTestingModule ], providers: [ diff --git a/frontend/src/app/widgets/records-summary-widget/records-summary-widget.component.spec.ts b/frontend/src/app/widgets/records-summary-widget/records-summary-widget.component.spec.ts index 45cbf865..2819cc87 100644 --- a/frontend/src/app/widgets/records-summary-widget/records-summary-widget.component.spec.ts +++ b/frontend/src/app/widgets/records-summary-widget/records-summary-widget.component.spec.ts @@ -1,16 +1,34 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { RecordsSummaryWidgetComponent } from './records-summary-widget.component'; +import {FastenApiService} from '../../services/fasten-api.service'; +import {HTTP_CLIENT_TOKEN} from '../../dependency-injection'; +import {HttpClient} from '@angular/common/http'; +import {RouterTestingModule} from '@angular/router/testing'; +import {of} from 'rxjs'; describe('RecordsSummaryWidgetComponent', () => { let component: RecordsSummaryWidgetComponent; let fixture: ComponentFixture; + let mockedFastenApiService beforeEach(async () => { + mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getSummary']) await TestBed.configureTestingModule({ - declarations: [ RecordsSummaryWidgetComponent ] + imports: [ RecordsSummaryWidgetComponent, RouterTestingModule ], + providers: [ + { + provide: FastenApiService, + useValue: mockedFastenApiService + }, + { + provide: HTTP_CLIENT_TOKEN, + useClass: HttpClient, + } + ] }) .compileComponents(); + mockedFastenApiService.getSummary.and.returnValue(of({})); fixture = TestBed.createComponent(RecordsSummaryWidgetComponent); component = fixture.componentInstance;