fixing frontend tests.

This commit is contained in:
Jason Kulatunga 2023-01-15 11:37:26 -08:00
parent e68900b1bc
commit b28bd3913f
17 changed files with 79 additions and 59 deletions

View File

@ -1,4 +1,5 @@
import { AddressModel } from './address-model';
import * as fixture from "../../fixtures/r4/datatypes/address.json"
describe('AddressModel', () => {
it('should create an instance', () => {
@ -6,7 +7,6 @@ describe('AddressModel', () => {
});
it('should parse fhirdata', () => {
let fixture = require("../../fixtures/r4/datatypes/address.json")
let expectedAddress = new AddressModel({})
expectedAddress.city = "SALEM"
expectedAddress.country = "US"

View File

@ -1,5 +1,6 @@
import { HumanNameModel } from './human-name-model';
import {AddressModel} from './address-model';
import * as fixture from "../../fixtures/r4/datatypes/human-name.json"
describe('HumanNameModel', () => {
it('should create an instance', () => {
@ -7,7 +8,6 @@ describe('HumanNameModel', () => {
});
it('should parse fhirdata', () => {
let fixture = require("../../fixtures/r4/datatypes/human-name.json")
let expectedHumanName = new HumanNameModel({})
expectedHumanName.givenName = 'Peter, James'
expectedHumanName.familyName = 'Windsor'

View File

@ -1,6 +1,7 @@
import { AdverseEventModel } from './adverse-event-model';
import {AllergyIntoleranceModel} from './allergy-intolerance-model';
import {CodableConceptModel} from '../datatypes/codable-concept-model';
import * as example1Fixture from "../../fixtures/r4/resources/adverseEvent/example1.json";
describe('AdverseEventModel', () => {
it('should create an instance', () => {
@ -10,7 +11,6 @@ describe('AdverseEventModel', () => {
describe('with r4', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/r4/resources/adverseEvent/example1.json")
let expected = new AdverseEventModel({})
expected.subject = {
"reference": "Patient/example"
@ -34,7 +34,7 @@ describe('AdverseEventModel', () => {
})
expected.has_event = true
expect(new AdverseEventModel(fixture)).toEqual(expected);
expect(new AdverseEventModel(example1Fixture)).toEqual(expected);
});
})
});

View File

@ -1,5 +1,12 @@
import {AllergyIntoleranceModel} from './allergy-intolerance-model';
import {fhirVersions} from '../constants';
import * as example1Fixture from "../../fixtures/r4/resources/allergyIntolerance/example1.json";
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 example1Stu3Fixture from "../../fixtures/stu3/resources/allergyIntolerance/example1.json"
import * as example2Stu3Fixture from "../../fixtures/stu3/resources/allergyIntolerance/example2.json"
describe('AllergyIntoleranceModel', () => {
it('should create an instance', () => {
@ -9,7 +16,6 @@ describe('AllergyIntoleranceModel', () => {
describe('with r4', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/r4/resources/allergyIntolerance/example1.json")
let expected = new AllergyIntoleranceModel({})
expected.title = 'Cashew nuts'
expected.status = 'Confirmed'
@ -27,11 +33,10 @@ describe('AllergyIntoleranceModel', () => {
expected.category = ['food']
expected.patient = {reference: 'Patient/example'}
expect(new AllergyIntoleranceModel(fixture)).toEqual(expected);
expect(new AllergyIntoleranceModel(example1Fixture)).toEqual(expected);
});
it('should parse r4 example2.json', () => {
let fixture = require("../../fixtures/r4/resources/allergyIntolerance/example2.json")
let expected = new AllergyIntoleranceModel({})
expected.title = 'Penicillin G'
expected.status = 'Unconfirmed'
@ -43,11 +48,10 @@ describe('AllergyIntoleranceModel', () => {
expected.category = ['medication']
expected.patient = {reference: 'Patient/example'}
expect(new AllergyIntoleranceModel(fixture)).toEqual(expected);
expect(new AllergyIntoleranceModel(example2Fixture)).toEqual(expected);
});
it('should parse r4 example3.json', () => {
let fixture = require("../../fixtures/r4/resources/allergyIntolerance/example3.json")
let expected = new AllergyIntoleranceModel({})
expected.title = 'No Known Allergy (situation)'
expected.status = 'Confirmed'
@ -59,13 +63,12 @@ describe('AllergyIntoleranceModel', () => {
// expected.category = [ 'food' ]
expected.patient = {reference: 'Patient/mom'}
expect(new AllergyIntoleranceModel(fixture)).toEqual(expected);
expect(new AllergyIntoleranceModel(example3Fixture)).toEqual(expected);
});
})
describe('with dstu2', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/dstu2/resources/allergyIntolerance/example1.json")
let expected = new AllergyIntoleranceModel({})
expected.title = "ALLERGENIC EXTRACT, PENICILLIN"
expected.status = 'unconfirmed'
@ -83,11 +86,10 @@ describe('AllergyIntoleranceModel', () => {
expected.category = ['medication']
expected.patient = {reference: 'Patient/example'}
expect(new AllergyIntoleranceModel(fixture, fhirVersions.DSTU2)).toEqual(expected);
expect(new AllergyIntoleranceModel(example3Fixture, fhirVersions.DSTU2)).toEqual(expected);
});
it('should parse example2.json', () => {
let fixture = require("../../fixtures/dstu2/resources/allergyIntolerance/example2.json")
let expected = new AllergyIntoleranceModel({})
expected.title = 'PENICILLINS'
expected.status = 'confirmed'
@ -105,14 +107,14 @@ describe('AllergyIntoleranceModel', () => {
expected.category = []
expected.patient = {reference: 'Patient/065b82c2aaa2'}
expect(new AllergyIntoleranceModel(fixture, fhirVersions.DSTU2)).toEqual(expected);
expect(new AllergyIntoleranceModel(example1DstuFixture, fhirVersions.DSTU2)).toEqual(expected);
});
})
describe('with stu3', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/stu3/resources/allergyIntolerance/example1.json")
let expected = new AllergyIntoleranceModel({})
expected.title = 'Cashew nuts'
expected.status = 'confirmed'
@ -130,11 +132,11 @@ describe('AllergyIntoleranceModel', () => {
expected.category = ['food']
expected.patient = {reference: 'Patient/example'}
expect(new AllergyIntoleranceModel(fixture, fhirVersions.STU3)).toEqual(expected);
expect(new AllergyIntoleranceModel(example1Stu3Fixture, fhirVersions.STU3)).toEqual(expected);
});
it('should parse example2.json', () => {
let fixture = require("../../fixtures/stu3/resources/allergyIntolerance/example2.json")
let expected = new AllergyIntoleranceModel({})
expected.title = 'Fish - dietary (substance)'
expected.status = 'confirmed'
@ -146,7 +148,7 @@ describe('AllergyIntoleranceModel', () => {
expected.category = ['food']
expected.patient = {reference: 'Patient/example'}
expect(new AllergyIntoleranceModel(fixture, fhirVersions.STU3)).toEqual(expected);
expect(new AllergyIntoleranceModel(example2Stu3Fixture, fhirVersions.STU3)).toEqual(expected);
});
})

View File

@ -1,5 +1,9 @@
import { CarePlanModel } from './care-plan-model';
import * as heartOperationPlanFixture from "../../fixtures/r4/resources/carePlan/heartOperationPlan.json"
import * as pregnancyPlanFixture from "../../fixtures/r4/resources/carePlan/pregnancyPlan.json"
import * as weightLossPlanFixture from "../../fixtures/r4/resources/carePlan/weightLossPlan.json"
describe('CarePlanModel', () => {
it('should create an instance', () => {
expect(new CarePlanModel({})).toBeTruthy();
@ -8,7 +12,7 @@ describe('CarePlanModel', () => {
describe('with r4', () => {
it('should parse heartOperationPlan.json', () => {
let fixture = require("../../fixtures/r4/resources/carePlan/heartOperationPlan.json")
let expected = new CarePlanModel({})
expected.status = "completed"
// expected.expiry = "completed"
@ -48,11 +52,11 @@ describe('CarePlanModel', () => {
// expected.category = ['food']
// expected.patient = {reference: 'Patient/example'}
expect(new CarePlanModel(fixture)).toEqual(expected);
expect(new CarePlanModel(heartOperationPlanFixture)).toEqual(expected);
});
it('should parse pregnancyPlan.json', () => {
let fixture = require("../../fixtures/r4/resources/carePlan/pregnancyPlan.json")
let expected = new CarePlanModel({})
expected.status = "active"
// expected.expiry = "completed"
@ -72,11 +76,11 @@ describe('CarePlanModel', () => {
expected.period_start = '2013-01-01'
expected.period_end = '2013-10-01'
expect(new CarePlanModel(fixture)).toEqual(expected);
expect(new CarePlanModel(pregnancyPlanFixture)).toEqual(expected);
});
it('should parse weightLossPlan.json', () => {
let fixture = require("../../fixtures/r4/resources/carePlan/weightLossPlan.json")
let expected = new CarePlanModel({})
expected.status = "active"
// expected.expiry = "completed"
@ -97,7 +101,7 @@ describe('CarePlanModel', () => {
// expected.periodStart = '2013-01-01'
expected.period_end = '2017-06-01'
expected.author = { reference: 'Practitioner/example', display: 'Dr Adam Careful' }
expect(new CarePlanModel(fixture)).toEqual(expected);
expect(new CarePlanModel(weightLossPlanFixture)).toEqual(expected);
});
})

View File

@ -2,6 +2,9 @@ import { CareTeamModel } from './care-team-model';
import {CarePlanModel} from './care-plan-model';
import {ReferenceModel} from '../datatypes/reference-model';
import * as fixture from "../../fixtures/r4/resources/careTeam/example1.json"
describe('CareTeamModel', () => {
it('should create an instance', () => {
expect(new CareTeamModel({})).toBeTruthy();
@ -10,7 +13,6 @@ describe('CareTeamModel', () => {
describe('with r4', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/r4/resources/careTeam/example1.json")
let expected = new CareTeamModel({})
expected.name = "Peter James Charlmers Care Plan for Inpatient Encounter"
expected.status = "active"

View File

@ -2,6 +2,11 @@ import { ConditionModel } from './condition-model';
import {CareTeamModel} from './care-team-model';
import {CodableConceptModel} from '../datatypes/codable-concept-model';
import * as example1Fixture from '../../fixtures/r4/resources/condition/example1.json';
import * as example2Fixture from '../../fixtures/r4/resources/condition/example2.json';
import * as example3Fixture from '../../fixtures/r4/resources/condition/example3.json';
describe('ConditionModel', () => {
it('should create an instance', () => {
expect(new ConditionModel({})).toBeTruthy();
@ -9,7 +14,7 @@ describe('ConditionModel', () => {
describe('with r4', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/r4/resources/condition/example1.json")
// let fixture = require("../../fixtures/r4/resources/condition/example1.json")
let expected = new ConditionModel({})
expected.code_text = 'Burn of ear'
expected.severity_text = 'Severe'
@ -30,10 +35,10 @@ describe('ConditionModel', () => {
// expected.dateRecorded: string | undefined
expected.onset_datetime = '2012-05-24'
expect(new ConditionModel(fixture)).toEqual(expected);
expect(new ConditionModel(example1Fixture)).toEqual(expected);
});
it('should parse example2.json', () => {
let fixture = require("../../fixtures/r4/resources/condition/example2.json")
let expected = new ConditionModel({})
expected.code_text = 'Asthma'
expected.severity_text = 'Mild'
@ -45,10 +50,9 @@ describe('ConditionModel', () => {
// expected.dateRecorded: string | undefined
// expected.onsetDateTime = '2012-05-24'
expect(new ConditionModel(fixture)).toEqual(expected);
expect(new ConditionModel(example2Fixture)).toEqual(expected);
});
it('should parse example3.json', () => {
let fixture = require("../../fixtures/r4/resources/condition/example3.json")
let expected = new ConditionModel({})
expected.code_text = 'Fever'
expected.severity_text = 'Mild'
@ -60,7 +64,7 @@ describe('ConditionModel', () => {
expected.date_recorded = '2013-04-04'
expected.onset_datetime = '2013-04-02'
expect(new ConditionModel(fixture)).toEqual(expected);
expect(new ConditionModel(example3Fixture)).toEqual(expected);
});
})

View File

@ -1,6 +1,9 @@
import { DeviceModel } from './device-model';
import {AdverseEventModel} from './adverse-event-model';
import {CodableConceptModel} from '../datatypes/codable-concept-model';
import * as fixture from "../../fixtures/r4/resources/device/example1.json"
import * as fixture2 from "../../fixtures/r4/resources/device/example2.json"
describe('DeviceModel', () => {
it('should create an instance', () => {
@ -10,7 +13,6 @@ describe('DeviceModel', () => {
describe('with r4', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/r4/resources/device/example1.json")
let expected = new DeviceModel({})
@ -18,12 +20,11 @@ describe('DeviceModel', () => {
});
it('should parse example2.json', () => {
let fixture = require("../../fixtures/r4/resources/device/example2.json")
let expected = new DeviceModel({})
expected.status = 'active'
expect(new DeviceModel(fixture)).toEqual(expected);
expect(new DeviceModel(fixture2)).toEqual(expected);
});
})

View File

@ -1,6 +1,8 @@
import { DiagnosticReportModel } from './diagnostic-report-model';
import {DeviceModel} from './device-model';
import {CodableConceptModel} from '../datatypes/codable-concept-model';
import example1Fixture from "../../fixtures/r4/resources/diagnosticReport/example1.json"
describe('DiagnosticReportModel', () => {
it('should create an instance', () => {
@ -10,7 +12,6 @@ describe('DiagnosticReportModel', () => {
describe('with r4', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/r4/resources/diagnosticReport/example1.json")
let expected = new DiagnosticReportModel({})
expected.title = 'Complete blood count (hemogram) panel - Blood by Automated count'
@ -26,7 +27,7 @@ describe('DiagnosticReportModel', () => {
expected.performer = { reference: 'Organization/f001', display: 'Burgers University Medical Centre' }
expected.issued = '2013-05-15T19:32:52+01:00'
expect(new DiagnosticReportModel(fixture)).toEqual(expected);
expect(new DiagnosticReportModel(example1Fixture)).toEqual(expected);
});
// it('should parse example2.json', () => {

View File

@ -1,6 +1,8 @@
import { DocumentReferenceModel } from './document-reference-model';
import {AdverseEventModel} from './adverse-event-model';
import {CodableConceptModel} from '../datatypes/codable-concept-model';
import * as example1Fixture from "../../fixtures/r4/resources/documentReference/example1.json"
describe('DocumentReferenceModel', () => {
it('should create an instance', () => {
@ -10,7 +12,6 @@ describe('DocumentReferenceModel', () => {
describe('with r4', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/r4/resources/documentReference/example1.json")
let expected = new DocumentReferenceModel({})
expected.description = 'Physical'
expected.status = 'current'
@ -28,7 +29,7 @@ describe('DocumentReferenceModel', () => {
}
// expected.context: any | undefined
expect(new DocumentReferenceModel(fixture)).toEqual(expected);
expect(new DocumentReferenceModel(example1Fixture)).toEqual(expected);
});
})

View File

@ -1,5 +1,9 @@
import { EncounterModel } from './encounter-model';
import {DocumentReferenceModel} from './document-reference-model';
import * as example1Fixture from "../../fixtures/r4/resources/encounter/example1.json"
import * as example2Fixture from "../../fixtures/r4/resources/encounter/example2.json"
import * as example3Fixture from "../../fixtures/r4/resources/encounter/example3.json"
describe('EncounterModel', () => {
it('should create an instance', () => {
@ -8,7 +12,6 @@ describe('EncounterModel', () => {
describe('with r4', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/r4/resources/encounter/example1.json")
let expected = new EncounterModel({})
// periodEnd: string | undefined
// periodStart: string | undefined
@ -19,11 +22,10 @@ describe('EncounterModel', () => {
expected.resource_status = 'in-progress'
// participant
expect(new EncounterModel(fixture)).toEqual(expected);
expect(new EncounterModel(example1Fixture)).toEqual(expected);
});
it('should parse example2.json', () => {
let fixture = require("../../fixtures/r4/resources/encounter/example2.json")
let expected = new EncounterModel({})
expected.period_end = '2015-01-17T16:30:00+10:00'
expected.period_start = '2015-01-17T16:00:00+10:00'
@ -41,11 +43,10 @@ describe('EncounterModel', () => {
}
]
expect(new EncounterModel(fixture)).toEqual(expected);
expect(new EncounterModel(example2Fixture)).toEqual(expected);
});
it('should parse example3.json', () => {
let fixture = require("../../fixtures/r4/resources/encounter/example3.json")
let expected = new EncounterModel({})
// expected.periodEnd = '2015-01-17T16:30:00+10:00'
// expected.periodStart = '2015-01-17T16:00:00+10:00'
@ -58,7 +59,7 @@ describe('EncounterModel', () => {
{ display: undefined, reference: Object({ reference: 'Practitioner/f201' }), text: undefined, periodStart: undefined }
]
expect(new EncounterModel(fixture)).toEqual(expected);
expect(new EncounterModel(example3Fixture)).toEqual(expected);
});
})

View File

@ -2,6 +2,9 @@ import { GoalModel } from './goal-model';
import {DocumentReferenceModel} from './document-reference-model';
import {CodableConceptModel} from '../datatypes/codable-concept-model';
import * as example1Fixture from "../../fixtures/r4/resources/goal/example1.json"
import * as example2Fixture from "../../fixtures/r4/resources/goal/example2.json"
describe('GoalModel', () => {
it('should create an instance', () => {
expect(new GoalModel({})).toBeTruthy();
@ -10,7 +13,6 @@ describe('GoalModel', () => {
describe('with r4', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/r4/resources/goal/example1.json")
let expected = new GoalModel({})
// expected.title: string | undefined
@ -33,11 +35,10 @@ describe('GoalModel', () => {
expected.subject = { reference: 'Patient/example', display: 'Peter James Chalmers' }
expected.status_date = '2016-02-14'
expect(new GoalModel(fixture)).toEqual(expected);
expect(new GoalModel(example1Fixture)).toEqual(expected);
});
it('should parse example2.json', () => {
let fixture = require("../../fixtures/r4/resources/goal/example2.json")
let expected = new GoalModel({})
// expected.title: string | undefined
@ -57,7 +58,7 @@ describe('GoalModel', () => {
expected.subject = { reference: 'Patient/example', display: 'Peter James Chalmers' }
// expected.statusDate = '2016-02-14'
expect(new GoalModel(fixture)).toEqual(expected);
expect(new GoalModel(example2Fixture)).toEqual(expected);
});
})

View File

@ -1,4 +1,5 @@
import { ImmunizationModel } from './immunization-model';
import * as example1Fixture from "../../fixtures/r4/resources/immunization/example1.json"
describe('ImmunizationModel', () => {
it('should create an instance', () => {
@ -7,7 +8,6 @@ describe('ImmunizationModel', () => {
describe('with r4', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/r4/resources/immunization/example1.json")
let expected = new ImmunizationModel({})
expected.title = 'Fluvax (Influenza)'
@ -29,7 +29,7 @@ describe('ImmunizationModel', () => {
expected.patient = { reference: 'Patient/example' }
expected.note = [ { text: 'Notes on adminstration of vaccine' } ]
expect(new ImmunizationModel(fixture)).toEqual(expected);
expect(new ImmunizationModel(example1Fixture)).toEqual(expected);
});
})
});

View File

@ -3,6 +3,9 @@ import {HumanNameModel} from '../datatypes/human-name-model';
import {AddressModel} from '../datatypes/address-model';
import {CodableConceptModel} from '../datatypes/codable-concept-model';
import {fhirVersions} from '../constants';
import * as example1Fixture from "../../fixtures/r4/resources/location/example1.json"
import * as example2Fixture from "../../fixtures/r4/resources/location/example2.json"
import * as example1Dstu2Fixture from "../../fixtures/dstu2/resources/location/example1.json"
describe('LocationModel', () => {
it('should create an instance', () => {
@ -11,7 +14,6 @@ describe('LocationModel', () => {
describe('with r4', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/r4/resources/location/example1.json")
let expectedLocation = new LocationModel({})
expectedLocation.name = 'South Wing, second floor'
expectedLocation.status = 'active'
@ -42,11 +44,10 @@ describe('LocationModel', () => {
]
})
expect(new LocationModel(fixture)).toEqual(expectedLocation);
expect(new LocationModel(example1Fixture)).toEqual(expectedLocation);
});
it('should parse example2.json', () => {
let fixture = require("../../fixtures/r4/resources/location/example2.json")
let expectedLocation = new LocationModel({})
expectedLocation.name = 'BUMC Ambulance'
expectedLocation.status = 'active'
@ -77,14 +78,13 @@ describe('LocationModel', () => {
]
})
expect(new LocationModel(fixture)).toEqual(expectedLocation);
expect(new LocationModel(example2Fixture)).toEqual(expectedLocation);
});
})
describe('with dstu2', () => {
it('should parse example1.json', () => {
let fixture = require("../../fixtures/dstu2/resources/location/example1.json")
let expectedLocation = new LocationModel({})
expectedLocation.name = "South Wing, second floor"
expectedLocation.status = 'active'
@ -132,7 +132,7 @@ describe('LocationModel', () => {
]
})
expect(new LocationModel(fixture, fhirVersions.DSTU2)).toEqual(expectedLocation);
expect(new LocationModel(example1Dstu2Fixture, fhirVersions.DSTU2)).toEqual(expectedLocation);
});
})
});

View File

@ -14,6 +14,7 @@ declare const require: {
};
};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,

View File

@ -25,7 +25,9 @@
"lib": [
"es2020",
"dom",
]
],
"resolveJsonModule": true,
"esModuleInterop": true
},
"angularCompilerOptions": {
//customizations

View File

@ -7,7 +7,7 @@
"outDir": "./out-tsc/spec",
"types": [
"jasmine",
]
],
},
"files": [
"src/test.ts",
@ -16,5 +16,5 @@
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
],
}