Skip to content

Commit 729c824

Browse files
feat: nsdToJson
1 parent 78e2e2f commit 729c824

File tree

204 files changed

+451386
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+451386
-0
lines changed

foundation/codecomponents/nsds.ts

Lines changed: 22369 additions & 0 deletions
Large diffs are not rendered by default.

index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ export {
7474
TreeSelection,
7575
} from "./tDataTypeTemplates/lNodeTypeToSelection.js";
7676

77+
export {
78+
LNodeDescription,
79+
NameSpaceDescription,
80+
nsdToJson,
81+
} from "./tDataTypeTemplates/nsdToJson.js";
82+
7783
export {
7884
Supervision,
7985
SupervisionOptions,
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { expect } from "chai";
2+
3+
import {
4+
nsd72,
5+
nsd73,
6+
nsd74,
7+
nsd7420,
8+
nsd81,
9+
} from "../foundation/codecomponents/nsds.js";
10+
import { lnClass74, lnClassData } from "./nsdToJson/testNsdJson.js";
11+
12+
import { nsdToJson } from "./nsdToJson.js";
13+
14+
const doc72 = new DOMParser().parseFromString(nsd72, "application/xml");
15+
const doc73 = new DOMParser().parseFromString(nsd73, "application/xml");
16+
const doc74 = new DOMParser().parseFromString(nsd74, "application/xml");
17+
const doc7420 = new DOMParser().parseFromString(nsd7420, "application/xml");
18+
const doc81 = new DOMParser().parseFromString(nsd81, "application/xml");
19+
20+
describe("NSD to Json parsing function", () => {
21+
it("return undefined for invalid ln class", () =>
22+
expect(nsdToJson("invalid")).to.be.undefined);
23+
24+
it("returns object that compares well to static 7-4 ln classes", async () => {
25+
lnClass74.forEach((lnClass) => {
26+
const data = nsdToJson(lnClass)!;
27+
const sClass = lnClassData[lnClass];
28+
29+
Object.keys(sClass).forEach((key) => {
30+
expect(data[key]).to.deep.equal(sClass[key]);
31+
});
32+
});
33+
});
34+
35+
it("returns object that compares well to static 7-420 classes", async () => {
36+
const data = nsdToJson("DSTK");
37+
expect(data).to.not.be.undefined;
38+
});
39+
40+
it("allows to pass non default NSD files", async () => {
41+
const data = nsdToJson("MMXU", {
42+
81: doc81,
43+
74: doc74,
44+
7420: doc7420,
45+
73: doc73,
46+
72: doc72,
47+
});
48+
expect(data).to.not.be.undefined;
49+
});
50+
});

0 commit comments

Comments
 (0)