diff --git a/tests/DCC/AdministrativeData.CalibrationLaboratory.test.ts b/tests/DCC/AdministrativeData.CalibrationLaboratory.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..251b2841b97112be1d844c0adbec2b6fbe871203 --- /dev/null +++ b/tests/DCC/AdministrativeData.CalibrationLaboratory.test.ts @@ -0,0 +1,80 @@ +/** + * @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)); + }); +}); diff --git a/tests/DCC/AdministrativeData.Customer.test.ts b/tests/DCC/AdministrativeData.Customer.test.ts index 377bf6e8e680e92d9836d693b6d301b2b2f46bc3..52388bebc539c1bf72586d93c1d8ed060ed02c60 100644 --- a/tests/DCC/AdministrativeData.Customer.test.ts +++ b/tests/DCC/AdministrativeData.Customer.test.ts @@ -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); } });