Skip to content
Snippets Groups Projects

Add tests

Merged Jan Loewe requested to merge feat-jest-tests into master
10 files
+ 13
11
Compare changes
  • Side-by-side
  • Inline
Files
10
import { select, toTextArr, toTextContentArr } from "../../../util";
import { CalibrationLaboratoryType, DCCDocument } from "../../../../src";
import { testRichContentType } from "../Types/RichContentType";
const base = "/dcc:digitalCalibrationCertificate/dcc:administrativeData/dcc:calibrationLaboratory/dcc:contact";
const xpath = {
name: `${base}/dcc:name`,
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`,
},
};
export const testCalibrationLaboratory = () => {
describe("CalibrationLaboratoryType", () => {
let dcc: DCCDocument, calibrationLaboratory: CalibrationLaboratoryType, dom;
beforeEach(() => {
({ dcc, dom } = xmlEnv.recreateEnv());
calibrationLaboratory = dcc.digitalCalibrationCertificate.administrativeData.calibrationLaboratory;
});
test("should get correct name from XML", () => {
testRichContentType(xpath.name, calibrationLaboratory.contact.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));
});
});
};
Loading