Skip to content
Snippets Groups Projects

Add tests

Merged Jan Loewe requested to merge feat-jest-tests into master
1 file
+ 42
0
Compare changes
  • Side-by-side
  • Inline
 
/**
 
* @jest-environment ./tests/XMLEnvironment.ts
 
* @xml ./tests/resources/example.xml
 
*/
 
 
import { select, toTextArr, toTextContentArr } from "../util";
 
import { RespPersonType, DCCDocument } from "../../src";
 
 
const base = "//dcc:administrativeData/dcc:respPersons";
 
const xpath = {
 
respPersons: {
 
respPerson: {
 
person: {
 
name: {
 
content: `${base}/dcc:respPerson[1]/dcc:person/dcc:name/dcc:content`,
 
},
 
},
 
mainSigner: `string(${base}/dcc:respPerson[1]/dcc:mainSigner)`,
 
},
 
},
 
};
 
 
describe("ContactType", () => {
 
let dcc: DCCDocument, respPerson: RespPersonType, dom;
 
 
beforeEach(async () => {
 
({ dcc, dom } = await xmlEnv.recreateEnv());
 
respPerson = dcc.digitalCalibrationCertificate.administrativeData.respPersons.respPerson[0];
 
});
 
 
test("should get correct res name content from XML", () => {
 
// get expected list from example xml
 
const expected = <Element[]>select(xpath.respPersons.respPerson.person.name.content, dom);
 
expect(toTextArr(respPerson.person.name.content)).toEqual(toTextContentArr(expected));
 
});
 
 
test("should get correct responsible person main signer flag from XML", () => {
 
expect(respPerson.mainSigner._text).toBe(select(xpath.respPersons.respPerson.mainSigner, dom));
 
});
 
 
/* TODO: setters */
 
});
Loading