From d8cc91d1d0d1c644901b74d09b1fbdede0ebb60c Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Mon, 16 Jan 2023 09:55:55 -0800 Subject: [PATCH] fixing tests. make we can mock FastenApiService in tests. --- ...port-medical-history-editor.component.spec.ts | 12 ++++++++++-- .../medical-history.component.spec.ts | 16 +++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/components/report-medical-history-editor/report-medical-history-editor.component.spec.ts b/frontend/src/app/components/report-medical-history-editor/report-medical-history-editor.component.spec.ts index 92ea50d9..c340c493 100644 --- a/frontend/src/app/components/report-medical-history-editor/report-medical-history-editor.component.spec.ts +++ b/frontend/src/app/components/report-medical-history-editor/report-medical-history-editor.component.spec.ts @@ -1,14 +1,22 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ReportMedicalHistoryEditorComponent } from './report-medical-history-editor.component'; +import {NgbActiveModal, NgbModalModule} from '@ng-bootstrap/ng-bootstrap'; +import {FastenApiService} from '../../services/fasten-api.service'; +import {HttpClient} from '@angular/common/http'; -describe('ReportEditorRelatedComponent', () => { +describe('ReportMedicalHistoryEditorComponent', () => { let component: ReportMedicalHistoryEditorComponent; let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ ReportMedicalHistoryEditorComponent ] + declarations: [ ReportMedicalHistoryEditorComponent ], + imports: [], + providers: [NgbActiveModal, { + provide: FastenApiService, + useValue: jasmine.createSpyObj('FastenApiService', ['createResourceComposition']) + }] }) .compileComponents(); diff --git a/frontend/src/app/pages/medical-history/medical-history.component.spec.ts b/frontend/src/app/pages/medical-history/medical-history.component.spec.ts index f3691c5c..61e8ff9a 100644 --- a/frontend/src/app/pages/medical-history/medical-history.component.spec.ts +++ b/frontend/src/app/pages/medical-history/medical-history.component.spec.ts @@ -1,16 +1,30 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MedicalHistoryComponent } from './medical-history.component'; +import {FastenApiService} from '../../services/fasten-api.service'; +import {HttpClient} from '@angular/common/http'; +import {NgbModal, NgbModalModule} from '@ng-bootstrap/ng-bootstrap'; +import {of} from 'rxjs'; describe('MedicalHistoryComponent', () => { let component: MedicalHistoryComponent; let fixture: ComponentFixture; + let mockedFastenApiService beforeEach(async () => { + + // httpClientSpy = jasmine.createSpyObj('HttpClient', ['get']); + // fastenApiService = new FastenApiService(httpClientSpy, ); + mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResourceGraph']) await TestBed.configureTestingModule({ - declarations: [ MedicalHistoryComponent ] + declarations: [ MedicalHistoryComponent ], + providers: [{ + provide: FastenApiService, + useValue: mockedFastenApiService + }, NgbModalModule] }) .compileComponents(); + mockedFastenApiService.getResourceGraph.and.returnValue(of({"Condition":[],"Encounter":[]})); fixture = TestBed.createComponent(MedicalHistoryComponent); component = fixture.componentInstance;