diff --git a/tests/DCC/AdministrativeData.SoftwareListType.test.ts b/tests/DCC/AdministrativeData.SoftwareListType.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..f68442ead6780d3a8fafae950e2bb255538315f5 --- /dev/null +++ b/tests/DCC/AdministrativeData.SoftwareListType.test.ts @@ -0,0 +1,53 @@ +/** + * @jest-environment ./tests/XMLEnvironment.ts + * @xml ./tests/resources/example.xml + */ + +import { select, toTextArr, toTextContentArr } from "../util"; +import { SoftwareListType, DCCDocument, SoftwareType } from "../../src"; + +const base = "//dcc:administrativeData/dcc:dccSoftware/dcc:software"; +const xpath = { + softwareNameContent: `${base}/dcc:name/dcc:content`, + softwareRelease: `string(${base}/dcc:release)`, + softwareType: "string(${base}/dcc:type)", + softwareDescription: "${base}/dcc:description", + softwareTypeId: "${base}/@id", + softwareTypeRefType: "${base}/@refType", +}; + +/* +TODO: DCC enthält mehrere Sprachen, dass muss für bestimmte Felder wie z.B. Name auf alle Sprachen geprüft und verglichen werden +* */ +describe("DccSoftwareType", () => { + let dcc: DCCDocument, dccSoftware: SoftwareListType, software: SoftwareType, dom; + + beforeEach(async () => { + ({ dcc, dom } = await xmlEnv.recreateEnv()); + dccSoftware = dcc.digitalCalibrationCertificate.administrativeData.dccSoftware; + software = dccSoftware.software[1]; /* TODO: evtl. nicht nur mit ersten Index testen */ + }); + + test("should get correct software name content from XML", () => { + // get expected list from example xml + const expected = <Element[]>select(xpath.softwareNameContent, dom); + expect(toTextArr(software.name.content)).toEqual(toTextContentArr(expected)); + }); + + test("should get correct software release version of software from XML", () => { + expect(software.release._text).toBe(select(xpath.softwareRelease, dom)); + }); + + test("should get correct software type of software from XML", () => { + expect(software.type._text).toBe(select(xpath.softwareType, dom)); + }); + /* TODO: description testen*/ + + test("should get correct software reftype ...", () => { + expect(software._attr.refType).toBe(select(xpath.softwareTypeRefType, dom)); + }); + + test("should get correct software id ...", () => { + expect(software._attr.id).toBe(select(xpath.softwareTypeId, dom)); + }); +});