|
| 1 | +import { expect } from "chai"; |
| 2 | + |
| 3 | +import { findElement } from "../foundation/helpers.test.js"; |
| 4 | + |
| 5 | +import { |
| 6 | + atccSelection, |
| 7 | + ltrkSelection, |
| 8 | + mmxuSelection, |
| 9 | +} from "./insertSelectedLNodeType.testdata.js"; |
| 10 | + |
| 11 | +import { |
| 12 | + incompleteAtccTypes, |
| 13 | + missingMmxuTypes, |
| 14 | + incompleteLtrkTypes, |
| 15 | + emptySSD, |
| 16 | +} from "./insertSelectedDataType.testfiles.js"; |
| 17 | + |
| 18 | +import { insertSelectedLNodeType } from "./insertSelectedLNodeType.js"; |
| 19 | + |
| 20 | +const incompleteMmxu = findElement(missingMmxuTypes) as XMLDocument; |
| 21 | +const imcompleteLtrk = findElement(incompleteLtrkTypes) as XMLDocument; |
| 22 | +const incompleteAtcc = findElement(incompleteAtccTypes) as XMLDocument; |
| 23 | +const missingDataTypes = findElement(emptySSD) as XMLDocument; |
| 24 | + |
| 25 | +describe("insertLNodeTypeSelection", () => { |
| 26 | + it("return empty array with invlaid lnClass", () => { |
| 27 | + expect( |
| 28 | + insertSelectedLNodeType(incompleteMmxu, mmxuSelection, "ERRO").length, |
| 29 | + ).to.equal(0); |
| 30 | + }); |
| 31 | + |
| 32 | + it("insert MMXU LNodeType including missing sub data", () => { |
| 33 | + const edits = insertSelectedLNodeType( |
| 34 | + incompleteMmxu, |
| 35 | + mmxuSelection, |
| 36 | + "MMXU", |
| 37 | + ); |
| 38 | + |
| 39 | + expect(edits.length).to.equal(6); |
| 40 | + |
| 41 | + const lNodeType = edits[0].node as Element; |
| 42 | + expect(lNodeType.tagName).to.equal("LNodeType"); |
| 43 | + expect(lNodeType.getAttribute("lnClass")).to.equal("MMXU"); |
| 44 | + expect(lNodeType.getAttribute("id")).to.equal( |
| 45 | + "MMXU$oscd$_3f831c4c0fa5f6bd", |
| 46 | + ); |
| 47 | + |
| 48 | + const doTypeCmv = edits[1].node as Element; |
| 49 | + expect(doTypeCmv.tagName).to.equal("DOType"); |
| 50 | + expect(doTypeCmv.getAttribute("cdc")).to.equal("CMV"); |
| 51 | + expect(doTypeCmv.getAttribute("id")).to.equal( |
| 52 | + "phsB$oscd$_3a6c99c1de0ca1c1", |
| 53 | + ); |
| 54 | + |
| 55 | + const doTypeWye = edits[2].node as Element; |
| 56 | + expect(doTypeWye.tagName).to.equal("DOType"); |
| 57 | + expect(doTypeWye.getAttribute("cdc")).to.equal("WYE"); |
| 58 | + expect(doTypeWye.getAttribute("id")).to.equal("A$oscd$_bd01f85651a2b3ee"); |
| 59 | + |
| 60 | + const daTypecVal = edits[3].node as Element; |
| 61 | + expect(daTypecVal.tagName).to.equal("DAType"); |
| 62 | + expect(daTypecVal.getAttribute("id")).to.equal( |
| 63 | + "cVal$oscd$_21f679e08734a896", |
| 64 | + ); |
| 65 | + |
| 66 | + const daTypeSBOw = edits[4].node as Element; |
| 67 | + expect(daTypeSBOw.tagName).to.equal("DAType"); |
| 68 | + expect(daTypeSBOw.getAttribute("id")).to.equal( |
| 69 | + "SBOw$oscd$_264aab113bc4c3d7", |
| 70 | + ); |
| 71 | + |
| 72 | + const enumType = edits[5].node as Element; |
| 73 | + expect(enumType.tagName).to.equal("EnumType"); |
| 74 | + expect(enumType.getAttribute("id")).to.equal( |
| 75 | + "stVal$oscd$_48ba16345b8e7f5b", |
| 76 | + ); |
| 77 | + }); |
| 78 | + |
| 79 | + it("insert LTRK LNodeType including missing sub data", () => { |
| 80 | + const edits = insertSelectedLNodeType( |
| 81 | + imcompleteLtrk, |
| 82 | + ltrkSelection, |
| 83 | + "LTRK", |
| 84 | + ); |
| 85 | + |
| 86 | + expect(edits.length).to.equal(7); |
| 87 | + |
| 88 | + const lNodeType = edits[0].node as Element; |
| 89 | + expect(lNodeType.tagName).to.equal("LNodeType"); |
| 90 | + expect(lNodeType.getAttribute("lnClass")).to.equal("LTRK"); |
| 91 | + expect(lNodeType.getAttribute("id")).to.equal( |
| 92 | + "LTRK$oscd$_f8074960800758df", |
| 93 | + ); |
| 94 | + |
| 95 | + const doTypeCmv = edits[1].node as Element; |
| 96 | + expect(doTypeCmv.tagName).to.equal("DOType"); |
| 97 | + expect(doTypeCmv.getAttribute("cdc")).to.equal("CTS"); |
| 98 | + expect(doTypeCmv.getAttribute("id")).to.equal( |
| 99 | + "ApcFTrk$oscd$_9039fc5f67d3778a", |
| 100 | + ); |
| 101 | + |
| 102 | + const doTypeWye = edits[2].node as Element; |
| 103 | + expect(doTypeWye.tagName).to.equal("DOType"); |
| 104 | + expect(doTypeWye.getAttribute("cdc")).to.equal("CTS"); |
| 105 | + expect(doTypeWye.getAttribute("id")).to.equal( |
| 106 | + "ApcIntTrk$oscd$_0b6b0a301af5aa77", |
| 107 | + ); |
| 108 | + |
| 109 | + const daTypecVal = edits[3].node as Element; |
| 110 | + expect(daTypecVal.tagName).to.equal("DAType"); |
| 111 | + expect(daTypecVal.getAttribute("id")).to.equal( |
| 112 | + "ctlVal$oscd$_ed49c2f7a55ad05a", |
| 113 | + ); |
| 114 | + |
| 115 | + const daTypeSBOw = edits[4].node as Element; |
| 116 | + expect(daTypeSBOw.tagName).to.equal("DAType"); |
| 117 | + expect(daTypeSBOw.getAttribute("id")).to.equal( |
| 118 | + "ctlVal$oscd$_5a5af9e249dc7f84", |
| 119 | + ); |
| 120 | + |
| 121 | + const enumTypeStVal = edits[5].node as Element; |
| 122 | + expect(enumTypeStVal.tagName).to.equal("EnumType"); |
| 123 | + expect(enumTypeStVal.getAttribute("id")).to.equal( |
| 124 | + "stVal$oscd$_74dd2cc4b188b4ad", |
| 125 | + ); |
| 126 | + |
| 127 | + const enumTypeOrCat = edits[6].node as Element; |
| 128 | + expect(enumTypeOrCat.tagName).to.equal("EnumType"); |
| 129 | + expect(enumTypeOrCat.getAttribute("id")).to.equal( |
| 130 | + "orCat$oscd$_929ee017c8f9feb5", |
| 131 | + ); |
| 132 | + }); |
| 133 | + |
| 134 | + it("insert ATCC LNodeType including missing sub data", () => { |
| 135 | + const edits = insertSelectedLNodeType( |
| 136 | + incompleteAtcc, |
| 137 | + atccSelection, |
| 138 | + "ATCC", |
| 139 | + ); |
| 140 | + |
| 141 | + expect(edits.length).to.equal(5); |
| 142 | + |
| 143 | + const lNodeType = edits[0].node as Element; |
| 144 | + expect(lNodeType.tagName).to.equal("LNodeType"); |
| 145 | + expect(lNodeType.getAttribute("lnClass")).to.equal("ATCC"); |
| 146 | + expect(lNodeType.getAttribute("id")).to.equal( |
| 147 | + "ATCC$oscd$_f9d7914eb0ce0e92", |
| 148 | + ); |
| 149 | + |
| 150 | + const doTypeCmv = edits[1].node as Element; |
| 151 | + expect(doTypeCmv.tagName).to.equal("DOType"); |
| 152 | + expect(doTypeCmv.getAttribute("cdc")).to.equal("APC"); |
| 153 | + expect(doTypeCmv.getAttribute("id")).to.equal( |
| 154 | + "VolSpt$oscd$_ef3a36fd78b41086", |
| 155 | + ); |
| 156 | + |
| 157 | + const daTypecVal = edits[2].node as Element; |
| 158 | + expect(daTypecVal.tagName).to.equal("DAType"); |
| 159 | + expect(daTypecVal.getAttribute("id")).to.equal( |
| 160 | + "SBOw$oscd$_61d7e600207c9456", |
| 161 | + ); |
| 162 | + |
| 163 | + const daTypeSBOw = edits[3].node as Element; |
| 164 | + expect(daTypeSBOw.tagName).to.equal("DAType"); |
| 165 | + expect(daTypeSBOw.getAttribute("id")).to.equal( |
| 166 | + "Oper$oscd$_5b11d63fa0ade588", |
| 167 | + ); |
| 168 | + |
| 169 | + const enumTypeOrCat = edits[4].node as Element; |
| 170 | + expect(enumTypeOrCat.tagName).to.equal("EnumType"); |
| 171 | + expect(enumTypeOrCat.getAttribute("id")).to.equal( |
| 172 | + "ctlModel$oscd$_e975941313cb546c", |
| 173 | + ); |
| 174 | + }); |
| 175 | + |
| 176 | + it("insert DataTypeTemplates when missing", () => { |
| 177 | + const edits = insertSelectedLNodeType( |
| 178 | + missingDataTypes, |
| 179 | + atccSelection, |
| 180 | + "ATCC", |
| 181 | + ); |
| 182 | + |
| 183 | + expect(edits.length).to.equal(19); |
| 184 | + |
| 185 | + const lNodeType = edits[0].node as Element; |
| 186 | + expect(lNodeType.tagName).to.equal("DataTypeTemplates"); |
| 187 | + }); |
| 188 | +}); |
0 commit comments