Skip to content

Commit

Permalink
test(smv): test for no supervision allowed and removing supervision
Browse files Browse the repository at this point in the history
  • Loading branch information
juancho0202 committed Oct 11, 2022
1 parent fb1c39d commit 22d0f54
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
8 changes: 8 additions & 0 deletions test/testfiles/editors/VS893-LaterBindingSMV-LSVS.scd
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@
</DAI>
</DOI>
</LN>
<LN lnClass="LSVS" inst="2" lnType="Dummy.LSVS">
<Private type="OpenSCD.create" />
<DOI name="SvCBRef">
<DAI name="setSrcRef">
<Val>SMV_Publisher2CurrentTransformer/LLN0.voltageOnly</Val>
</DAI>
</DOI>
</LN>
</LDevice>
</Server>
</AccessPoint>
Expand Down
42 changes: 40 additions & 2 deletions test/unit/editors/subscription/supervision.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { expect } from '@open-wc/testing';

import {
instantiateSubscriptionSupervision,
// removeSubscriptionSupervision,
removeSubscriptionSupervision,
} from '../../../../src/editors/subscription/foundation.js';

import { Create } from '../../../../src/foundation.js';
import { Create, Delete } from '../../../../src/foundation.js';

describe('supervision', () => {
let doc: XMLDocument;
Expand All @@ -25,6 +25,11 @@ describe('supervision', () => {
controlElement = doc.querySelector(
'IED[name="SMV_Publisher4"] SampledValueControl[name="voltageOnly"]'
)!;
subscriberIED = doc.querySelector('IED[name="SMV_Subscriber3"]')!;
const noSupervisionAllowedActions: Create[] =
instantiateSubscriptionSupervision(controlElement, subscriberIED);
expect(noSupervisionAllowedActions).to.have.length(0);

subscriberIED = doc.querySelector('IED[name="SMV_Subscriber2"]')!;
const createActions: Create[] = instantiateSubscriptionSupervision(
controlElement,
Expand Down Expand Up @@ -63,5 +68,38 @@ describe('supervision', () => {
expect(lnParent.nodeName).to.be.equal('LN');
expect(newDoiElement.nodeName).to.be.equal('DOI');
});

it('removes the correct elements when supervision is removed', () => {
controlElement = doc.querySelector(
'IED[name="SMV_Publisher2"] SampledValueControl[name="fullSmv"]'
)!;
subscriberIED = doc.querySelector('IED[name="SMV_Subscriber"]')!;
const removeActions: Delete[] = removeSubscriptionSupervision(
controlElement,
subscriberIED
);
expect(removeActions).to.have.length(1);
const removeAction: Delete = removeActions[0];
const parentElement: Node = removeAction.old.parent;
const element: Node = removeAction.old.element;
expect(parentElement).to.exist;
expect(element).to.exist;
expect(parentElement.nodeName).to.be.equal('LN');
expect(element.nodeName).to.be.equal('DOI');

controlElement = doc.querySelector(
'IED[name="SMV_Publisher2"] SampledValueControl[name="voltageOnly"]'
)!;
const removeActionsWithRemovedLn: Delete[] =
removeSubscriptionSupervision(controlElement, subscriberIED);
expect(removeActionsWithRemovedLn).to.have.length(1);
const removeLnAction: Delete = removeActionsWithRemovedLn[0];
const lnParent: Node = removeLnAction.old.parent;
const lnElement: Node = removeLnAction.old.element;
expect(lnParent).to.exist;
expect(lnElement).to.exist;
expect(lnParent.nodeName).to.be.equal('LDevice');
expect(lnElement.nodeName).to.be.equal('LN');
});
});
});

0 comments on commit 22d0f54

Please sign in to comment.