Skip to content

Commit

Permalink
fix(wizards/fcda): make sure lnInst is non empty string (#512)
Browse files Browse the repository at this point in the history
* fix(wizards/fcda): make sure lnInst is non empty string

* refactor(wizards/fcda): improve readablity
  • Loading branch information
JakobVogelsang authored Jan 25, 2022
1 parent 24c271c commit f8d2dc7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/wizards/fcda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ function newFCDA(parent: Element, path: string[]): Element | undefined {
const ldInst = ln.closest('LDevice')?.getAttribute('inst');
const prefix = ln.getAttribute('prefix') ?? '';
const lnClass = ln.getAttribute('lnClass');
const lnInst = ln.getAttribute('inst') ?? '';
const lnInst =
(ln.getAttribute('inst') && ln.getAttribute('inst') !== '')
? ln.getAttribute('inst')
: null;

let doName = '';
let daName = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ describe('FCDA editing wizarding integration', () => {
expect(
doc.querySelector(
'DataSet > FCDA[ldInst="CircuitBreaker_CB1"]' +
'[prefix=""][lnClass="LLN0"][lnInst=""][doName="Beh"][daName="stVal"][fc="ST"]'
'[prefix=""][lnClass="LLN0"]:not(lnInst)[doName="Beh"][daName="stVal"][fc="ST"]'
)
).to.not.exist;
await primaryAction.click();
expect(
doc.querySelector(
'DataSet > FCDA[ldInst="CircuitBreaker_CB1"]' +
'[prefix=""][lnClass="LLN0"][lnInst=""][doName="Beh"][daName="stVal"][fc="ST"]'
'[prefix=""][lnClass="LLN0"]:not(lnInst)[doName="Beh"][daName="stVal"][fc="ST"]'
)
).to.exist;
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/wizards/fcda.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('create wizard for FCDA element', () => {
expect(newElement).to.have.attribute('ldInst', 'CircuitBreaker_CB1');
expect(newElement).to.have.attribute('prefix', '');
expect(newElement).to.have.attribute('lnClass', 'LLN0');
expect(newElement).to.have.attribute('lnInst', '');
expect(newElement).to.not.have.attribute('lnInst');
expect(newElement).to.have.attribute('doName', 'Beh');
expect(newElement).to.have.attribute('daName', 'stVal');
expect(newElement).to.have.attribute('fc', 'ST');
Expand Down

0 comments on commit f8d2dc7

Please sign in to comment.