UNPKG

@vidal-community/vidal-web-components

Version:

Vidal Web Components

32 lines 1.69 kB
import { Patient } from './patient'; import { assert } from '@open-wc/testing'; suite('patient class', () => { const nowSupplier = () => new Date('2022-01-04').getTime(); test('constructor set date to display in correct format', () => { const patient = new Patient('male', '1983-06-15', nowSupplier); assert.deepEqual(patient.dateOfBirth, new Date('1983-06-15')); }); test('invalid date provided in constructor is ignored', () => { [ new Patient('female', '1967-13-11', nowSupplier), new Patient('male', '1976-05-32', nowSupplier), new Patient('female', '1987-36-3', nowSupplier), new Patient('male', '1998/03/08', nowSupplier), new Patient('female', '1987-6-2', nowSupplier), new Patient('female', 'Not a date', nowSupplier), ].forEach((patient) => { var _a; return assert.isUndefined(patient.dateOfBirth, (_a = patient.dateOfBirth) === null || _a === void 0 ? void 0 : _a.toString()); }); }); test('compute patient age from date of birth', () => { [ { patient: new Patient('male', undefined, nowSupplier), age: undefined }, { patient: new Patient('female', '1974-09-27', nowSupplier), age: 47 }, { patient: new Patient('unknown', '1977-05-02', nowSupplier), age: 44 }, { patient: new Patient('unknown', '1994-07-19', nowSupplier), age: 27 }, { patient: new Patient('female', '2050-09-27', nowSupplier), age: undefined, }, ].forEach((param) => assert.equal(param.patient.age, param.age)); }); }); //# sourceMappingURL=patient_test.js.map