From 18f8b36a39853321cf220d3d7c0cb9b1e32a308d Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Mon, 16 Jan 2023 07:55:53 -0800 Subject: [PATCH] fixing frontend tests. --- .../fhir-resource-outlet.directive.spec.ts | 70 ++++++++++++++++++- .../components/list-generic-resource/utils.ts | 2 +- ...ort-medical-history-condition.component.ts | 2 +- .../lib/models/resources/care-team-model.ts | 10 +-- .../lib/models/resources/encounter-model.ts | 4 +- 5 files changed, 78 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/components/fhir/fhir-resource/fhir-resource-outlet.directive.spec.ts b/frontend/src/app/components/fhir/fhir-resource/fhir-resource-outlet.directive.spec.ts index c0de34d6..512ab875 100644 --- a/frontend/src/app/components/fhir/fhir-resource/fhir-resource-outlet.directive.spec.ts +++ b/frontend/src/app/components/fhir/fhir-resource/fhir-resource-outlet.directive.spec.ts @@ -1,8 +1,76 @@ import { FhirResourceOutletDirective } from './fhir-resource-outlet.directive'; +import { + ComponentFactory, ComponentRef, + EmbeddedViewRef, EnvironmentInjector, + Injector, + NgModuleRef, + TemplateRef, + Type, + ViewContainerRef +} from '@angular/core'; + +class TestViewContainerRef extends ViewContainerRef { + get element(): import("@angular/core").ElementRef { + throw new Error("Method not implemented."); + } + get injector(): import("@angular/core").Injector { + throw new Error("Method not implemented."); + } + get parentInjector(): import("@angular/core").Injector { + throw new Error("Method not implemented."); + } + clear(): void { + throw new Error("Method not implemented."); + } + get(index: number): import("@angular/core").ViewRef { + throw new Error("Method not implemented."); + } + get length(): number { + throw new Error("Method not implemented."); + } + // createEmbeddedView(templateRef: import("@angular/core").TemplateRef, context?: C, index?: number): import("@angular/core").EmbeddedViewRef { + // throw new Error("Method not implemented."); + // } + // createComponent(componentFactory: import("@angular/core").ComponentFactory, index?: number, injector?: import("@angular/core").Injector, projectableNodes?: any[][], ngModule?: import("@angular/core").NgModuleRef): import("@angular/core").ComponentRef { + // throw new Error("Method not implemented."); + // } + insert(viewRef: import("@angular/core").ViewRef, index?: number): import("@angular/core").ViewRef { + throw new Error("Method not implemented."); + } + move(viewRef: import("@angular/core").ViewRef, currentIndex: number): import("@angular/core").ViewRef { + throw new Error("Method not implemented."); + } + indexOf(viewRef: import("@angular/core").ViewRef): number { + throw new Error("Method not implemented."); + } + remove(index?: number): void { + throw new Error("Method not implemented."); + } + detach(index?: number): import("@angular/core").ViewRef { + throw new Error("Method not implemented."); + } + + createComponent(componentType: Type, options?: { index?: number; injector?: Injector; ngModuleRef?: NgModuleRef; environmentInjector?: EnvironmentInjector | NgModuleRef; projectableNodes?: Node[][] }): ComponentRef; + createComponent(componentFactory: ComponentFactory, index?: number, injector?: Injector, projectableNodes?: any[][], environmentInjector?: EnvironmentInjector | NgModuleRef): ComponentRef; + createComponent(componentType, options?: { index?: number; injector?: Injector; ngModuleRef?: NgModuleRef; environmentInjector?: EnvironmentInjector | NgModuleRef; projectableNodes?: Node[][] } | number, injector?: Injector, projectableNodes?: any[][], environmentInjector?: EnvironmentInjector | NgModuleRef): ComponentRef { + throw new Error("Method not implemented."); + } + + createEmbeddedView(templateRef: TemplateRef, context?: C, options?: { index?: number; injector?: Injector }): EmbeddedViewRef; + createEmbeddedView(templateRef: TemplateRef, context?: C, index?: number): EmbeddedViewRef; + createEmbeddedView(templateRef, context?, options?: { index?: number; injector?: Injector } | number): EmbeddedViewRef { + throw new Error("Method not implemented."); + } + +} + + describe('FhirResourceOutletDirective', () => { + + it('should create an instance', () => { - const directive = new FhirResourceOutletDirective(); + const directive = new FhirResourceOutletDirective(new TestViewContainerRef()); expect(directive).toBeTruthy(); }); }); diff --git a/frontend/src/app/components/list-generic-resource/utils.ts b/frontend/src/app/components/list-generic-resource/utils.ts index debe355d..a46ddd7c 100644 --- a/frontend/src/app/components/list-generic-resource/utils.ts +++ b/frontend/src/app/components/list-generic-resource/utils.ts @@ -1,4 +1,4 @@ -import * as moment from 'moment' +import moment from "moment"; /** * Walks thru an object (ar array) and returns the value found at the provided diff --git a/frontend/src/app/components/report-medical-history-condition/report-medical-history-condition.component.ts b/frontend/src/app/components/report-medical-history-condition/report-medical-history-condition.component.ts index 6fe372c1..29519185 100644 --- a/frontend/src/app/components/report-medical-history-condition/report-medical-history-condition.component.ts +++ b/frontend/src/app/components/report-medical-history-condition/report-medical-history-condition.component.ts @@ -111,7 +111,7 @@ export class ReportMedicalHistoryConditionComponent implements OnInit { this.encounters.push(resource as EncounterModel); (resource as EncounterModel).participant.map((participant) => { - let id = participant.reference + let id = participant.reference.reference involvedInCareMap[id] = _.mergeWith( {}, involvedInCareMap[id], diff --git a/frontend/src/lib/models/resources/care-team-model.ts b/frontend/src/lib/models/resources/care-team-model.ts index 737be620..0d7c0ca8 100644 --- a/frontend/src/lib/models/resources/care-team-model.ts +++ b/frontend/src/lib/models/resources/care-team-model.ts @@ -12,11 +12,11 @@ export class CareTeamModel extends FastenDisplayModel { period_start: string | undefined period_end: string | undefined participants: { - reference:string - display:string, - role:string, - periodStart: string, - periodEnd: string + reference?: string, + display?:string, + role?:string, + periodStart?: string, + periodEnd?: string }[] | undefined category: CodableConceptModel[] | undefined subject: ReferenceModel | undefined diff --git a/frontend/src/lib/models/resources/encounter-model.ts b/frontend/src/lib/models/resources/encounter-model.ts index fe91b662..94b051aa 100644 --- a/frontend/src/lib/models/resources/encounter-model.ts +++ b/frontend/src/lib/models/resources/encounter-model.ts @@ -18,7 +18,7 @@ export class EncounterModel extends FastenDisplayModel { participant: { display?: string, role?: string, - reference?: string, + reference?: ReferenceModel, text?: string, periodStart?:string }[] | undefined @@ -85,7 +85,7 @@ export class EncounterModel extends FastenDisplayModel { return { role: _.get(item, 'type[0].text') || _.get(item, 'type[0].coding[0].display'), display: _.get(item, 'individual.display'), - reference: _.get(item, 'individual.reference'), + reference: _.get(item, 'individual'), text: _.get(item, 'type[0].text'), periodStart, };