Skip to content

Commit c484905

Browse files
fix(tDataTypeTemplate): make insertSelection insensitive to incorrect EnumTypes
1 parent 96ddefb commit c484905

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

tDataTypeTemplates/insertSelecetdLNodeType.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { findElement } from "../foundation/helpers.test.js";
44

55
import {
66
atccSelection,
7+
invalidSelection,
78
ltrkSelection,
89
mmxuSelection,
910
} from "./insertSelectedLNodeType.testdata.js";
@@ -29,6 +30,9 @@ describe("insertLNodeTypeSelection", () => {
2930
).to.equal(0);
3031
});
3132

33+
it('is insensitive for invalid EnumTypes',()=>
34+
insertSelectedLNodeType(incompleteMmxu, invalidSelection, "LLN0"))
35+
3236
it("insert MMXU LNodeType including missing sub data", () => {
3337
const edits = insertSelectedLNodeType(
3438
incompleteMmxu,

tDataTypeTemplates/insertSelectedLNodeType.testdata.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,78 @@ export const atccSelection = {
353353
},
354354
},
355355
};
356+
357+
358+
export const invalidSelection = {
359+
"Mod": {
360+
"Oper": {
361+
"ctlVal": {
362+
"on": {},
363+
"blocked": {},
364+
"test": {},
365+
"test/blocked": {}
366+
},
367+
"origin": {
368+
"orCat": {
369+
"not-supported": {},
370+
"bay-control": {},
371+
"station-control": {},
372+
"remote-control": {},
373+
"automatic-bay": {},
374+
"automatic-station": {},
375+
"automatic-remote": {},
376+
"maintenance": {},
377+
"process": {}
378+
},
379+
"orIdent": {}
380+
},
381+
"ctlNum": {},
382+
"T": {},
383+
"Test": {},
384+
"Check": {}
385+
},
386+
"stVal": {
387+
"on": {},
388+
"blocked": {},
389+
"test": {},
390+
"test/blocked": {}
391+
},
392+
"q": {},
393+
"t": {},
394+
"ctlModel": {
395+
"status-only": {},
396+
"direct-with-normal-security": {}
397+
}
398+
},
399+
"Beh": {
400+
"stVal": {
401+
"on": {},
402+
"blocked": {},
403+
"test": {},
404+
"test/blocked": {},
405+
"off": {}
406+
},
407+
"q": {},
408+
"t": {}
409+
},
410+
"Health": {
411+
"stVal": {
412+
"Waiting": {},
413+
"Test": {},
414+
"Ok": {},
415+
"Warning": {},
416+
"Alarm": {}
417+
},
418+
"q": {},
419+
"t": {}
420+
},
421+
"NamPlt": {
422+
"vendor": {},
423+
"swRev": {},
424+
"d": {},
425+
"configRev": {},
426+
"paramRev": {},
427+
"valRev": {},
428+
"ldNs": {}
429+
}
430+
};

tDataTypeTemplates/insertSelectedLNodeType.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ export function insertSelectedLNodeType(
214214
const vals: Element[] = [];
215215

216216
for (const content of Object.keys(sel)) {
217-
const ord = enumData[content].literalVal;
217+
const enumVal = enumData[content];
218+
if(!enumVal) continue; // check for invalid selection
219+
220+
const ord = enumVal.literalVal;
218221
const val = createElement(doc, "EnumVal", { ord });
219222
val.textContent = content;
220223
vals.push(val);

0 commit comments

Comments
 (0)