Skip to content
Snippets Groups Projects

Add tests

Merged Jan Loewe requested to merge feat-jest-tests into master
2 files
+ 8
2
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 56
0
/**
* @jest-environment ./tests/XMLEnvironment.ts
* @xml ./tests/resources/GP_Temperature_v3.2.0_DCC.xml
*/
import { select, toTextArr, toTextContentArr } from "../util";
import { DCCDocument } from "../../src";
const base = "//dcc:quantity[@refType='test_noQuantity']/dcc:noQuantity";
const xpath = {
noQuantity: {
name: {
content: `string(${base}/dcc:name/dcc:content)`,
},
content: `string(${base}/dcc:content)`,
file: {
fileName: `string(${base}/dcc:file/dcc:fileName)`,
mimeType: `string(${base}/dcc:file/dcc:mimeType)`,
dataBase64: `string(${base}/dcc:file/dcc:dataBase64)`,
},
formula: {
latex: `string(${base}/dcc:formula/dcc:latex)`,
},
},
};
describe("noQuantity", () => {
let dcc: DCCDocument, dom, result;
beforeEach(() => {
({ dcc, dom } = xmlEnv.recreateEnv());
result = dcc.digitalCalibrationCertificate.measurementResults.measurementResult[0].results.result[0];
});
test("should get correct name from XML", () => {
const expected = <Element[]>select(xpath.noQuantity.name.content, dom);
expect(toTextArr(result.data.quantity[0].noQuantity.name.content)[0]).toBe(expected);
});
test("should get correct content from XML", () => {
expect(result.data.quantity[0].noQuantity.content[0]._text).toBe(select(xpath.noQuantity.content, dom));
});
test("should get correct fileName from XML", () => {
expect(result.data.quantity[0].noQuantity.file[0].fileName._text).toBe(select(xpath.noQuantity.file.fileName, dom));
});
test("should get correct mimeType from XML", () => {
expect(result.data.quantity[0].noQuantity.file[0].mimeType._text).toBe(select(xpath.noQuantity.file.mimeType, dom));
});
test("should get correct latex formula from XML", () => {
expect(result.data.quantity[0].noQuantity.formula[0].latex._text).toBe(select(xpath.noQuantity.formula.latex, dom));
});
});
Loading