Skip to content
Snippets Groups Projects
Verified Commit 676a4794 authored by Jan Loewe's avatar Jan Loewe :speech_balloon:
Browse files

refactor(tests): small improvements and formatting

parent 590f6bc4
No related branches found
No related tags found
3 merge requests!10Refactor Test Resources,!6Adaptations for new DCC V3.2.1,!5Add tests
Pipeline #18617 failed
This commit is part of merge request !5. Comments created here will be created in the context of that merge request.
...@@ -3,10 +3,8 @@ ...@@ -3,10 +3,8 @@
* @xml ./tests/resources/GP_Temperature_Complete_DCC.xml * @xml ./tests/resources/GP_Temperature_Complete_DCC.xml
*/ */
import * as fc from "fast-check"; import { select } from "../util";
import { indexOf, select, toTextArr, toTextContentArr } from "../util"; import { DCCDocument } from "../../src";
import { CoreDataType, DCCDocument, DCCXMLElement } from "../../src";
import { string_ISO639_1 } from "../Arbitraries";
const base = "//dcc:quantity[@refType='test_charsXMLList']"; const base = "//dcc:quantity[@refType='test_charsXMLList']";
const xpath = { const xpath = {
......
...@@ -3,23 +3,21 @@ ...@@ -3,23 +3,21 @@
* @xml ./tests/resources/GP_Temperature_Complete_DCC.xml * @xml ./tests/resources/GP_Temperature_Complete_DCC.xml
*/ */
import * as fc from "fast-check"; import { select } from "../util";
import { indexOf, select, toTextArr, toTextContentArr } from "../util"; import { DCCDocument } from "../../src";
import { CoreDataType, DCCDocument, DCCXMLElement } from "../../src";
import { string_ISO639_1 } from "../Arbitraries";
const base = "//dcc:quantity[@refType='test_noQuantity']"; const base = "//dcc:quantity[@refType='test_noQuantity']/dcc:noQuantity";
const xpath = { const xpath = {
noQuantity: { noQuantity: {
name: `string(${base}/dcc:noQuantity/dcc:name)`, name: `string(${base}/dcc:name)`,
content: `string(${base}/dcc:noQuantity/dcc:content)`, content: `string(${base}/dcc:content)`,
file: { file: {
fileName: `string(${base}/dcc:noQuantity/dcc:file/dcc:fileName)`, fileName: `string(${base}/dcc:file/dcc:fileName)`,
mimeType: `string(${base}/dcc:noQuantity/dcc:file/dcc:mimeType)`, mimeType: `string(${base}/dcc:file/dcc:mimeType)`,
dataBase64: `string(${base}/dcc:noQuantity/dcc:file/dcc:dataBase64)`, dataBase64: `string(${base}/dcc:file/dcc:dataBase64)`,
}, },
formula: { formula: {
latex: `string(${base}/dcc:noQuantity/dcc:formula/dcc:latex)`, latex: `string(${base}/dcc:formula/dcc:latex)`,
}, },
}, },
}; };
...@@ -35,15 +33,19 @@ describe("noQuantity", () => { ...@@ -35,15 +33,19 @@ describe("noQuantity", () => {
test("should get correct name from XML", () => { test("should get correct name from XML", () => {
expect(result.data.quantity[0].noQuantity.name._text).toBe(select(xpath.noQuantity.name, dom)); expect(result.data.quantity[0].noQuantity.name._text).toBe(select(xpath.noQuantity.name, dom));
}); });
test("should get correct content from XML", () => { test("should get correct content from XML", () => {
expect(result.data.quantity[0].noQuantity.content[0]._text).toBe(select(xpath.noQuantity.content, dom)); expect(result.data.quantity[0].noQuantity.content[0]._text).toBe(select(xpath.noQuantity.content, dom));
}); });
test("should get correct fileName from XML", () => { test("should get correct fileName from XML", () => {
expect(result.data.quantity[0].noQuantity.file[0].fileName._text).toBe(select(xpath.noQuantity.file.fileName, dom)); expect(result.data.quantity[0].noQuantity.file[0].fileName._text).toBe(select(xpath.noQuantity.file.fileName, dom));
}); });
test("should get correct mimeType from XML", () => { test("should get correct mimeType from XML", () => {
expect(result.data.quantity[0].noQuantity.file[0].mimeType._text).toBe(select(xpath.noQuantity.file.mimeType, dom)); 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", () => { 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)); expect(result.data.quantity[0].noQuantity.formula[0].latex._text).toBe(select(xpath.noQuantity.formula.latex, dom));
}); });
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<dcc:digitalCalibrationCertificate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dcc="https://ptb.de/dcc" xmlns:si="https://ptb.de/si" xsi:schemaLocation="https://ptb.de/dcc https://ptb.de/dcc/v3.1.2/dcc.xsd" schemaVersion="3.1.2"> <dcc:digitalCalibrationCertificate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dcc="https://ptb.de/dcc" xmlns:si="https://ptb.de/si" xsi:schemaLocation="https://ptb.de/dcc https://ptb.de/dcc/v3.2.0/dcc.xsd" schemaVersion="3.2.0">
<dcc:administrativeData> <dcc:administrativeData>
<dcc:dccSoftware> <dcc:dccSoftware>
<dcc:software> <dcc:software>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment