From 0d28d88b95b7ec38844d5343e58fa8a6afca0a08 Mon Sep 17 00:00:00 2001 From: Muhammed-Ali Demir <muhammed.demir@ptb.de> Date: Wed, 5 Apr 2023 10:13:05 +0200 Subject: [PATCH] test: updated tests for ad customer and ad coreData --- tests/DCC/CoreDataType.test.ts | 66 ---------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 tests/DCC/CoreDataType.test.ts diff --git a/tests/DCC/CoreDataType.test.ts b/tests/DCC/CoreDataType.test.ts deleted file mode 100644 index 2a0d3ac..0000000 --- a/tests/DCC/CoreDataType.test.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @jest-environment ./tests/XMLEnvironment.ts - * @xml ./tests/resources/example.xml - */ - -import * as fc from "fast-check"; -import { indexOf, select, toTextArr, toTextContentArr } from "../util"; -import { CoreDataType, DCCDocument, DCCXMLElement } from "../../src"; -import { string_ISO639_1 } from "../Arbitraries"; - -const base = "/dcc:digitalCalibrationCertificate/dcc:administrativeData/dcc:coreData"; -const xpath = { - countryCodeISO3166_1: `string(${base}/dcc:countryCodeISO3166_1)`, - usedLangCodeISO639_1: `${base}/dcc:usedLangCodeISO639_1`, -}; - -describe("CoreDataType", () => { - let dcc: DCCDocument, coreData: CoreDataType, dom; - - beforeEach(async () => { - ({ dcc, dom } = await xmlEnv.recreateEnv()); - coreData = dcc.digitalCalibrationCertificate.administrativeData.coreData; - }); - - test("should get correct countryCodeISO3166_1 from XML", () => { - expect(coreData.countryCodeISO3166_1._text).toBe(select(xpath.countryCodeISO3166_1, dom)); - }); - - test("should get correct usedLangCodeISO639_1 from XML", () => { - // get expected list from example xml - const expected = <Element[]>select(xpath.usedLangCodeISO639_1, dom); - expect(toTextArr(coreData.usedLangCodeISO639_1)).toEqual(toTextContentArr(expected)); - }); - - test("should set usedLangCodeISO639_1 correctly", () => { - fc.assert( - fc.property(string_ISO639_1(), (str) => { - // add new element to array - coreData.usedLangCodeISO639_1.push(new DCCXMLElement({ _text: str })); - - // get actual list from xml - const actual = <Element[]>select(xpath.usedLangCodeISO639_1, dcc); - - expect(toTextArr(coreData.usedLangCodeISO639_1)).toContain(str); - expect(toTextContentArr(actual)).toContain(str); - }), - ); - }); - - test("should delete usedLangCodeISO639_1 correctly", () => { - const selection = toTextContentArr(<Element[]>select(xpath.usedLangCodeISO639_1, dom)); - fc.assert( - fc.property(fc.constantFrom(...selection), (str) => { - // get index and remove element from array - const index = indexOf(coreData.usedLangCodeISO639_1, str); - coreData.usedLangCodeISO639_1.splice(index, 1); - - // get actual list from xml - const actual = <Element[]>select(xpath.usedLangCodeISO639_1, dcc); - - expect(toTextArr(coreData.usedLangCodeISO639_1)).not.toContain(str); - expect(toTextContentArr(actual)).not.toContain(str); - }), - ); - }); -}); -- GitLab