Skip to content
Snippets Groups Projects

Add tests

Merged Jan Loewe requested to merge feat-jest-tests into master
1 file
+ 53
0
Compare changes
  • Side-by-side
  • Inline
/**
* @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));
});
});
Loading