Skip to content
Snippets Groups Projects

Add tests

Merged Jan Loewe requested to merge feat-jest-tests into master
Compare and Show latest version
26 files
+ 2777
4
Compare changes
  • Side-by-side
  • Inline
Files
26
/**
* @jest-environment ./tests/XMLEnvironment.ts
* @xml ./tests/resources/Test_DCC_Minimal.xml
*/
import { select, toTextArr, toTextContentArr } from "../../util";
import { CalibrationLaboratoryType, DCCDocument } from "../../../src";
const base = "/dcc:digitalCalibrationCertificate/dcc:administrativeData/dcc:calibrationLaboratory/dcc:contact";
const xpath = {
name: `string(${base}/dcc:name/dcc:content)`,
location: {
city: `${base}/dcc:location/dcc:city`,
},
};
describe("Test_DCC_Minimal: CalibrationLaboratoryType", () => {
let dcc: DCCDocument, calibrationLaboratory: CalibrationLaboratoryType, dom;
beforeEach(async () => {
({ dcc, dom } = await xmlEnv.recreateEnv());
calibrationLaboratory = dcc.digitalCalibrationCertificate.administrativeData.calibrationLaboratory;
});
test("should get correct name from XML", () => {
expect(calibrationLaboratory.contact.name.content[0]._text).toBe(select(xpath.name, dom));
});
test("should get correct city from XML", () => {
// get expected list from example xml
const expected = <Element[]>select(xpath.location.city, dom);
expect(toTextArr(calibrationLaboratory.contact.location.city)).toEqual(toTextContentArr(expected));
});
});
Loading