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