From dabb4fe135c6803c8e255aa230252057e4ecae29 Mon Sep 17 00:00:00 2001 From: Muhammed-Ali Demir <muhammed.demir@ptb.de> Date: Wed, 14 Jun 2023 05:10:15 +0000 Subject: [PATCH] test: added tests for reftype, id of reportAmendedSubstituted and item... --- .../AdministrativeData.CoreDataType.test.ts | 26 ++++++++++++------- .../AdministrativeData.Items.Item.test.ts | 21 +++++++++++++++ tests/resources/GP_Temperature_v3.2.1_DCC.xml | 2 +- tests/resources/example.xml | 2 +- 4 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 tests/DCC/GP_Temperatur_v3.2.1_DCC/AdministrativeData.Items.Item.test.ts diff --git a/tests/DCC/GP_Temperatur_v3.2.1_DCC/AdministrativeData.CoreDataType.test.ts b/tests/DCC/GP_Temperatur_v3.2.1_DCC/AdministrativeData.CoreDataType.test.ts index e271495..7d9e8e7 100644 --- a/tests/DCC/GP_Temperatur_v3.2.1_DCC/AdministrativeData.CoreDataType.test.ts +++ b/tests/DCC/GP_Temperatur_v3.2.1_DCC/AdministrativeData.CoreDataType.test.ts @@ -6,13 +6,13 @@ import { select } from "../../util"; import { CoreDataType, DCCDocument } from "../../../src"; -const base = "/dcc:digitalCalibrationCertificate/dcc:administrativeData/dcc:coreData"; +const base = "/dcc:digitalCalibrationCertificate/dcc:administrativeData/dcc:coreData/dcc:reportAmendedSubstituted"; const xpath = { - coreData: { - reportAmendedSubstituted: { - typeOfChange: `string(${base}/dcc:reportAmendedSubstituted/dcc:typeOfChange)`, - replacedUniqueIdentifier: `string(${base}/dcc:reportAmendedSubstituted/dcc:replacedUniqueIdentifier)`, - }, + reportAmendedSubstituted: { + typeOfChange: `string(${base}/dcc:typeOfChange)`, + replacedUniqueIdentifier: `string(${base}/dcc:replacedUniqueIdentifier)`, + refType: `string(${base}//@refType)`, + id: `string(${base}//@id)`, }, }; @@ -25,12 +25,18 @@ describe("GP_Temperature_v3.2.1_DCC: CoreDataType", () => { }); test("should get correct reportAmendedSubstituted typeOfChange from XML", () => { - expect(coreData.reportAmendedSubstituted.typeOfChange._text).toBe(select(xpath.coreData.reportAmendedSubstituted.typeOfChange, dom)); + expect(coreData.reportAmendedSubstituted.typeOfChange._text).toBe(select(xpath.reportAmendedSubstituted.typeOfChange, dom)); }); test("should get correct reportAmendedSubstituted replacedUniqueIdentifier from XML", () => { - expect(coreData.reportAmendedSubstituted.replacedUniqueIdentifier._text).toBe( - select(xpath.coreData.reportAmendedSubstituted.replacedUniqueIdentifier, dom), - ); + expect(coreData.reportAmendedSubstituted.replacedUniqueIdentifier._text).toBe(select(xpath.reportAmendedSubstituted.replacedUniqueIdentifier, dom)); + }); + + test("should get correct reportAmendedSubstituted refType from XML", () => { + expect(coreData.reportAmendedSubstituted._attr.refType).toBe(select(xpath.reportAmendedSubstituted.refType, dom)); + }); + + test("should get correct reportAmendedSubstituted id from XML", () => { + expect(coreData.reportAmendedSubstituted._attr.id).toBe(select(xpath.reportAmendedSubstituted.id, dom)); }); }); diff --git a/tests/DCC/GP_Temperatur_v3.2.1_DCC/AdministrativeData.Items.Item.test.ts b/tests/DCC/GP_Temperatur_v3.2.1_DCC/AdministrativeData.Items.Item.test.ts new file mode 100644 index 0000000..08474c9 --- /dev/null +++ b/tests/DCC/GP_Temperatur_v3.2.1_DCC/AdministrativeData.Items.Item.test.ts @@ -0,0 +1,21 @@ +/** + * @jest-environment ./tests/XMLEnvironment.ts + * @xml ./tests/resources/GP_Temperature_v3.2.1_DCC.xml + */ + +import { DCCDocument, ItemType } from "../../../src"; + +describe("GP_Temperature_v3.2.1_DCC: ItemType", () => { + let dcc: DCCDocument, item: ItemType, dom; + + beforeEach(() => { + ({ dcc, dom } = xmlEnv.recreateEnv()); + item = dcc.digitalCalibrationCertificate.administrativeData.items.item[0]; + }); + + test("should get item manufacturer null from XML", () => { + expect(item.manufacturer).toBeUndefined(); + }); + + /* TODO: setters */ +}); diff --git a/tests/resources/GP_Temperature_v3.2.1_DCC.xml b/tests/resources/GP_Temperature_v3.2.1_DCC.xml index 6e46ec6..29db7ff 100644 --- a/tests/resources/GP_Temperature_v3.2.1_DCC.xml +++ b/tests/resources/GP_Temperature_v3.2.1_DCC.xml @@ -55,7 +55,7 @@ <dcc:endPerformanceDate>1957-08-13</dcc:endPerformanceDate> <dcc:performanceLocation>laboratory</dcc:performanceLocation> <dcc:issueDate>2022-12-31</dcc:issueDate> - <dcc:reportAmendedSubstituted> + <dcc:reportAmendedSubstituted id="R2D2" refType="test_reportAmendedSubstituted"> <!-- TODO: refType und id hinzufügen --> <dcc:typeOfChange>amended</dcc:typeOfChange> <dcc:replacedUniqueIdentifier>GP_DCC_temperature_minimal_3.2.0_Complete</dcc:replacedUniqueIdentifier> </dcc:reportAmendedSubstituted> diff --git a/tests/resources/example.xml b/tests/resources/example.xml index e4dec5e..f2e67bf 100644 --- a/tests/resources/example.xml +++ b/tests/resources/example.xml @@ -134,7 +134,7 @@ <dcc:statement refType="basic_validityRange"> <dcc:declaration> <dcc:content lang="de">Angabe des Temperaturbereichs, in dem kalibriert wurde:</dcc:content> - <dcc:content lang="de">Specification of the temperature range in which calibration was performed:</dcc:content> + <dcc:content lang="en">Specification of the temperature range in which calibration was performed:</dcc:content> </dcc:declaration> <dcc:data> <dcc:quantity refType="basic_validityRangeMin"> -- GitLab