Skip to content
Snippets Groups Projects
Commit b576567e authored by Moritz Jordan's avatar Moritz Jordan
Browse files

test: add AdministrativeData Calibration Laboratory

parent 0d28d88b
No related branches found
No related tags found
3 merge requests!10Refactor Test Resources,!6Adaptations for new DCC V3.2.1,!5Add tests
Pipeline #19246 passed
This commit is part of merge request !5. Comments created here will be created in the context of that merge request.
/**
* @jest-environment ./tests/XMLEnvironment.ts
* @xml ./tests/resources/example.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)`,
eMail: `string(${base}/dcc:eMail)`,
phone: `string(${base}/dcc:phone)`,
fax: `string(${base}/dcc:fax)`,
location: {
city: `${base}/dcc:location/dcc:city`,
countryCode: `${base}/dcc:location/dcc:countryCode`,
postCode: `${base}/dcc:location/dcc:postCode`,
street: `${base}/dcc:location/dcc:street`,
streetNo: `${base}/dcc:location/dcc:streetNo`,
further: `${base}/dcc:location/dcc:further/dcc:content`,
},
};
describe("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 eMail from XML", () => {
expect(calibrationLaboratory.contact.eMail._text).toBe(select(xpath.eMail, dom));
});
test("should get correct phone from XML", () => {
expect(calibrationLaboratory.contact.phone._text).toBe(select(xpath.phone, 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));
});
test("should get correct countryCode from XML", () => {
// get expected list from example xml
const expected = <Element[]>select(xpath.location.countryCode, dom);
expect(toTextArr(calibrationLaboratory.contact.location.countryCode)).toEqual(toTextContentArr(expected));
});
test("should get correct postCode from XML", () => {
// get expected list from example xml
const expected = <Element[]>select(xpath.location.postCode, dom);
expect(toTextArr(calibrationLaboratory.contact.location.postCode)).toEqual(toTextContentArr(expected));
});
test("should get correct street from XML", () => {
// get expected list from example xml
const expected = <Element[]>select(xpath.location.street, dom);
expect(toTextArr(calibrationLaboratory.contact.location.street)).toEqual(toTextContentArr(expected));
});
test("should get correct streetNo from XML", () => {
// get expected list from example xml
const expected = <Element[]>select(xpath.location.streetNo, dom);
expect(toTextArr(calibrationLaboratory.contact.location.streetNo)).toEqual(toTextContentArr(expected));
});
test("should get correct further element from XML", () => {
// get expected list from example xml
const expected = <Element[]>select(xpath.location.further, dom);
expect(toTextArr(calibrationLaboratory.contact.location.further[0].content)).toEqual(toTextContentArr(expected));
});
});
......@@ -68,7 +68,7 @@ describe("ContactType", () => {
test("should get correct customer location further from XML", () => {
const expected = <Element[]>select(xpath.customer.location.further, dom);
for (var i = 0; i < expected.length; i++) {
for (let i = 0; i < expected.length; i++) {
expect(customer.location.further[0].content[i]._text).toBe(expected[i].textContent);
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment