Skip to content

Commit

Permalink
fixing fhir-resource tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Jan 16, 2023
1 parent d0c1e17 commit 36902b5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class ReportMedicalHistoryConditionComponent implements OnInit {
}

genResourceId(relatedResource: ResourceFhir): string {
return `/source/${relatedResource.source_id}/resource/${relatedResource.source_resource_type}/${relatedResource.source_resource_id}`
return `/source/${relatedResource?.source_id}/resource/${relatedResource?.source_resource_type}/${relatedResource?.source_resource_id}`
}

}
13 changes: 12 additions & 1 deletion frontend/src/app/pages/report-labs/report-labs.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ReportLabsComponent } from './report-labs.component';
import {FastenApiService} from '../../services/fasten-api.service';
import {NgbModalModule} from '@ng-bootstrap/ng-bootstrap';
import {of} from 'rxjs';

describe('ReportLabsComponent', () => {
let component: ReportLabsComponent;
let fixture: ComponentFixture<ReportLabsComponent>;
let mockedFastenApiService

beforeEach(async () => {

mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResources'])
await TestBed.configureTestingModule({
declarations: [ ReportLabsComponent ]
declarations: [ ReportLabsComponent ],
providers: [{
provide: FastenApiService,
useValue: mockedFastenApiService
}]
})
.compileComponents();
mockedFastenApiService.getResources.and.returnValue(of([]));

fixture = TestBed.createComponent(ReportLabsComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import * as example1Fixture from "../../fixtures/r4/resources/allergyIntolerance
import * as example2Fixture from "../../fixtures/r4/resources/allergyIntolerance/example2.json";
import * as example3Fixture from "../../fixtures/r4/resources/allergyIntolerance/example3.json";

import * as example1DstuFixture from "../../fixtures/dstu2/resources/allergyIntolerance/example2.json"
import * as example1DstuFixture from "../../fixtures/dstu2/resources/allergyIntolerance/example1.json"
import * as example2DstuFixture from "../../fixtures/dstu2/resources/allergyIntolerance/example2.json"
import * as example1Stu3Fixture from "../../fixtures/stu3/resources/allergyIntolerance/example1.json"
import * as example2Stu3Fixture from "../../fixtures/stu3/resources/allergyIntolerance/example2.json"

Expand Down Expand Up @@ -86,7 +87,7 @@ describe('AllergyIntoleranceModel', () => {
expected.category = ['medication']
expected.patient = {reference: 'Patient/example'}

expect(new AllergyIntoleranceModel(example3Fixture, fhirVersions.DSTU2)).toEqual(expected);
expect(new AllergyIntoleranceModel(example1DstuFixture, fhirVersions.DSTU2)).toEqual(expected);
});

it('should parse example2.json', () => {
Expand All @@ -107,7 +108,7 @@ describe('AllergyIntoleranceModel', () => {
expected.category = []
expected.patient = {reference: 'Patient/065b82c2aaa2'}

expect(new AllergyIntoleranceModel(example1DstuFixture, fhirVersions.DSTU2)).toEqual(expected);
expect(new AllergyIntoleranceModel(example2DstuFixture, fhirVersions.DSTU2)).toEqual(expected);
});

})
Expand Down

0 comments on commit 36902b5

Please sign in to comment.