|
| 1 | +import { expect } from "chai"; |
| 2 | +import { describeLogControl } from "./LogControl.js"; |
| 3 | + |
| 4 | +const scl = new DOMParser().parseFromString( |
| 5 | + `<SCL xmlns="http://www.iec.ch/61850/2003/SCL" > |
| 6 | + <IED name="IED1"> |
| 7 | + <AccessPoint name="AP1"> |
| 8 | + <Server> |
| 9 | + <LDevice inst="lDevice"> |
| 10 | + <LN0 lnClass="LLN0" inst="" lnType="LLN0"> |
| 11 | + <DataSet name="baseDataSet" > |
| 12 | + <FCDA iedName="IED1" ldInst="lDevice" lnClass="XCBR" lnInst="1" doName="Pos" daName="stVal" fc="ST" /> |
| 13 | + <FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="XCBR" lnInst="1" doName="Pos" daName="q" fc="ST" /> |
| 14 | + <FCDA iedName="IED1" ldInst="lDevice" lnClass="LLN0" doName="Beh" daName="stVal" fc="ST" /> |
| 15 | + <FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="LLN0" lnInst="" doName="Beh" fc="ST" /> |
| 16 | + </DataSet> |
| 17 | + <DataSet name="equalDataSet" > |
| 18 | + <FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="XCBR" lnInst="1" doName="Pos" daName="stVal" fc="ST" /> |
| 19 | + <FCDA iedName="IED1" ldInst="lDevice" lnClass="XCBR" lnInst="1" doName="Pos" daName="q" fc="ST" /> |
| 20 | + <FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="LLN0" lnInst="" doName="Beh" daName="stVal" fc="ST" /> |
| 21 | + <FCDA iedName="IED1" ldInst="lDevice" lnClass="LLN0" doName="Beh" fc="ST" /> |
| 22 | + </DataSet> |
| 23 | + <DataSet name="diffDataSet" > |
| 24 | + <Private type="private" /> |
| 25 | + <FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="XCBR" lnInst="1" doName="Pos" daName="stVal" fc="ST" /> |
| 26 | + <FCDA iedName="IED1" ldInst="lDevice" lnClass="XCBR" lnInst="1" doName="Pos" daName="q" fc="ST" /> |
| 27 | + <FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="LLN0" lnInst="" doName="Beh" daName="stVal" fc="ST" /> |
| 28 | + <FCDA iedName="IED1" ldInst="lDevice" lnClass="LLN0" doName="Beh" fc="ST" /> |
| 29 | + </DataSet> |
| 30 | + <DataSet name="invalidDataSet" > |
| 31 | + <FCDA ldInst="lDevice" prefix="" lnClass="XCBR" lnInst="1" doName="Pos" daName="stVal" fc="ST" /> |
| 32 | + </DataSet> |
| 33 | + <DataSet name="invalidDataSet" > |
| 34 | + <FCDA ldInst="lDevice" prefix="" lnClass="XCBR" lnInst="1" doName="Pos" daName="stVal" fc="ST" /> |
| 35 | + </DataSet> |
| 36 | + <LogControl name="baseLogControl" datSet="baseDataSet" ldInst="lDevice" prefix="" lnClass="LLN0" logName="logName" logEna="true" bufTime="0" > |
| 37 | + <TrgOps dchg="false" qchg="false" dupd="false" period="false" gi="false" /> |
| 38 | + </LogControl> |
| 39 | + <LogControl name="diffLogControl" datSet="diffDataSet" intgPd="1000" reasonCode="false" logEna="false" logName="logName" > |
| 40 | + <TrgOps dchg="false" qchg="true" dupd="false" period="true" gi="false" /> |
| 41 | + </LogControl> |
| 42 | + <LogControl name="equalLogControl" datSet="equalDataSet" ldInst="lDevice" logName="logName" reasonCode="true" /> |
| 43 | + <LogControl name="missingLogName" datSet="diffDataSet" /> |
| 44 | + <LogControl name="invalidLogControl" datSet="invalidDataSet" /> |
| 45 | + </LN0> |
| 46 | + </LDevice> |
| 47 | + </Server> |
| 48 | + </AccessPoint> |
| 49 | + </IED> |
| 50 | + </SCL>`, |
| 51 | + "application/xml" |
| 52 | +); |
| 53 | + |
| 54 | +const baseLogControl = scl.querySelector(`LogControl[name="baseLogControl"]`)!; |
| 55 | +const equalLogControl = scl.querySelector( |
| 56 | + 'LogControl[name="equalLogControl"]' |
| 57 | +)!; |
| 58 | +const diffLogControl = scl.querySelector('LogControl[name="diffLogControl"]')!; |
| 59 | +const invalidLogControl = scl.querySelector( |
| 60 | + 'LogControl[name="invalidLogControl"]' |
| 61 | +)!; |
| 62 | +const missingLogName = scl.querySelector('LogControl[name="missingLogName"]')!; |
| 63 | + |
| 64 | +describe("Description for SCL schema type LogControl", () => { |
| 65 | + it("returns undefined with invalid data", () => |
| 66 | + expect(describeLogControl(invalidLogControl)).to.be.undefined); |
| 67 | + |
| 68 | + it("returns undefined with invalid logName attribute", () => |
| 69 | + expect(describeLogControl(missingLogName)).to.be.undefined); |
| 70 | + |
| 71 | + it("returns same description with semantically equal Control's", () => |
| 72 | + expect(JSON.stringify(describeLogControl(baseLogControl))).to.equal( |
| 73 | + JSON.stringify(describeLogControl(equalLogControl)) |
| 74 | + )); |
| 75 | + |
| 76 | + it("returns different description with unequal Control elements", () => |
| 77 | + expect(JSON.stringify(describeLogControl(baseLogControl))).to.not.equal( |
| 78 | + JSON.stringify(describeLogControl(diffLogControl)) |
| 79 | + )); |
| 80 | +}); |
0 commit comments