Skip to content

Commit 8b45754

Browse files
author
Dennis Labordus
committed
Fixed Snapshots for integration.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent 639b6a1 commit 8b45754

File tree

5 files changed

+59
-93
lines changed

5 files changed

+59
-93
lines changed

test/integration/Setting.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ import '../../src/open-scd.js';
44

55
import { OpenSCD } from '../../src/open-scd.js';
66
import { newLoadNsdocEvent } from "../../src/Setting.js";
7+
import { cleanLocalStorageForNsdocFiles } from "../unit/foundation/nsdoc.test.js";
78

89
describe('Setting', () => {
910
let element: OpenSCD;
1011

1112
beforeEach(async () => {
13+
cleanLocalStorageForNsdocFiles();
14+
1215
element = await fixture(html`
1316
<open-scd></open-scd>
1417

test/integration/__snapshots__/Setting.test.snap.js

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,8 @@ snapshots["Setting upload .nsdoc file using event and looks like latest snapshot
11821182
</mwc-icon>
11831183
</mwc-list-item>
11841184
<mwc-list-item
1185-
aria-disabled="false"
1185+
aria-disabled="true"
1186+
disabled=""
11861187
graphic="avatar"
11871188
hasmeta=""
11881189
id="IEC 61850-7-3"
@@ -1193,24 +1194,16 @@ snapshots["Setting upload .nsdoc file using event and looks like latest snapshot
11931194
<span>
11941195
IEC 61850-7-3
11951196
</span>
1196-
<span slot="secondary">
1197-
1010X1
1198-
</span>
11991197
<mwc-icon
12001198
slot="graphic"
1201-
style="color:green;"
1202-
>
1203-
done
1204-
</mwc-icon>
1205-
<mwc-icon
1206-
id="deleteNsdocItem"
1207-
slot="meta"
1199+
style="color:red;"
12081200
>
1209-
delete
1201+
close
12101202
</mwc-icon>
12111203
</mwc-list-item>
12121204
<mwc-list-item
1213-
aria-disabled="false"
1205+
aria-disabled="true"
1206+
disabled=""
12141207
graphic="avatar"
12151208
hasmeta=""
12161209
id="IEC 61850-7-4"
@@ -1221,24 +1214,16 @@ snapshots["Setting upload .nsdoc file using event and looks like latest snapshot
12211214
<span>
12221215
IEC 61850-7-4
12231216
</span>
1224-
<span slot="secondary">
1225-
2007B3
1226-
</span>
12271217
<mwc-icon
12281218
slot="graphic"
1229-
style="color:green;"
1219+
style="color:red;"
12301220
>
1231-
done
1232-
</mwc-icon>
1233-
<mwc-icon
1234-
id="deleteNsdocItem"
1235-
slot="meta"
1236-
>
1237-
delete
1221+
close
12381222
</mwc-icon>
12391223
</mwc-list-item>
12401224
<mwc-list-item
1241-
aria-disabled="false"
1225+
aria-disabled="true"
1226+
disabled=""
12421227
graphic="avatar"
12431228
hasmeta=""
12441229
id="IEC 61850-8-1"
@@ -1249,20 +1234,11 @@ snapshots["Setting upload .nsdoc file using event and looks like latest snapshot
12491234
<span>
12501235
IEC 61850-8-1
12511236
</span>
1252-
<span slot="secondary">
1253-
1010X1
1254-
</span>
12551237
<mwc-icon
12561238
slot="graphic"
1257-
style="color:green;"
1258-
>
1259-
done
1260-
</mwc-icon>
1261-
<mwc-icon
1262-
id="deleteNsdocItem"
1263-
slot="meta"
1239+
style="color:red;"
12641240
>
1265-
delete
1241+
close
12661242
</mwc-icon>
12671243
</mwc-list-item>
12681244
</mwc-list>

test/integration/__snapshots__/open-scd.test.snap.js

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,8 @@ snapshots["open-scd looks like its snapshot"] =
11731173
</mwc-icon>
11741174
</mwc-list-item>
11751175
<mwc-list-item
1176-
aria-disabled="false"
1176+
aria-disabled="true"
1177+
disabled=""
11771178
graphic="avatar"
11781179
hasmeta=""
11791180
id="IEC 61850-7-3"
@@ -1184,24 +1185,16 @@ snapshots["open-scd looks like its snapshot"] =
11841185
<span>
11851186
IEC 61850-7-3
11861187
</span>
1187-
<span slot="secondary">
1188-
1010X1
1189-
</span>
11901188
<mwc-icon
11911189
slot="graphic"
1192-
style="color:green;"
1193-
>
1194-
done
1195-
</mwc-icon>
1196-
<mwc-icon
1197-
id="deleteNsdocItem"
1198-
slot="meta"
1190+
style="color:red;"
11991191
>
1200-
delete
1192+
close
12011193
</mwc-icon>
12021194
</mwc-list-item>
12031195
<mwc-list-item
1204-
aria-disabled="false"
1196+
aria-disabled="true"
1197+
disabled=""
12051198
graphic="avatar"
12061199
hasmeta=""
12071200
id="IEC 61850-7-4"
@@ -1212,24 +1205,16 @@ snapshots["open-scd looks like its snapshot"] =
12121205
<span>
12131206
IEC 61850-7-4
12141207
</span>
1215-
<span slot="secondary">
1216-
1010X1
1217-
</span>
12181208
<mwc-icon
12191209
slot="graphic"
1220-
style="color:green;"
1221-
>
1222-
done
1223-
</mwc-icon>
1224-
<mwc-icon
1225-
id="deleteNsdocItem"
1226-
slot="meta"
1210+
style="color:red;"
12271211
>
1228-
delete
1212+
close
12291213
</mwc-icon>
12301214
</mwc-list-item>
12311215
<mwc-list-item
1232-
aria-disabled="false"
1216+
aria-disabled="true"
1217+
disabled=""
12331218
graphic="avatar"
12341219
hasmeta=""
12351220
id="IEC 61850-8-1"
@@ -1240,20 +1225,11 @@ snapshots["open-scd looks like its snapshot"] =
12401225
<span>
12411226
IEC 61850-8-1
12421227
</span>
1243-
<span slot="secondary">
1244-
1010X1
1245-
</span>
12461228
<mwc-icon
12471229
slot="graphic"
1248-
style="color:green;"
1249-
>
1250-
done
1251-
</mwc-icon>
1252-
<mwc-icon
1253-
id="deleteNsdocItem"
1254-
slot="meta"
1230+
style="color:red;"
12551231
>
1256-
delete
1232+
close
12571233
</mwc-icon>
12581234
</mwc-list-item>
12591235
</mwc-list>

test/integration/open-scd.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ import { html, fixture, expect } from '@open-wc/testing';
33
import '../../src/open-scd.js';
44
import { newEmptySCD } from '../../src/schemas.js';
55
import { OpenSCD } from '../../src/open-scd.js';
6+
import { cleanLocalStorageForNsdocFiles } from "../unit/foundation/nsdoc.test.js";
67

78
describe('open-scd', () => {
89
let element: OpenSCD;
910
let invalidSCL: string;
1011
let validSCL: string;
1112

1213
beforeEach(async () => {
14+
cleanLocalStorageForNsdocFiles();
15+
1316
invalidSCL = await fetch('/test/testfiles/invalid2007B.scd').then(
1417
response => response.text()
1518
);

test/unit/foundation/nsdoc.test.ts

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,53 +63,53 @@ describe('nsdoc', () => {
6363
it('returns the lnClass in case no title can be found', async function () {
6464
const ln = validSCL.querySelector(
6565
'IED[name="IED1"] > AccessPoint[name="P1"] > Server > LDevice[inst="CircuitBreaker_CB1"] > LN[lnClass="XCBR"]');
66-
66+
6767
expect(nsdocsObject.getDataDescription(ln!).label).to.eql('XCBR');
6868
});
6969
});
7070

7171
describe('which for DO elements', () => {
7272
it('returns the description', async function () {
7373
const dataObject = validSCL.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Beh"]');
74-
74+
7575
expect(nsdocsObject.getDataDescription(dataObject!).label).to.eql('Some DO description');
7676
});
77-
77+
7878
it('returns the description where the DO is part of a parent class', async function () {
7979
const dataObject = validSCL.querySelector('LNodeType[id="Dummy.XCBR1"] > DO[name="Beh"]');
80-
80+
8181
expect(nsdocsObject.getDataDescription(dataObject!).label).to.eql('Some DomainLN Description');
8282
});
83-
83+
8484
it('returns the name in case no description can be found', async function () {
8585
const dataObject = validSCL.querySelector('LNodeType[id="Dummy.LLN0"] > DO[name="Health"]');
86-
86+
8787
expect(nsdocsObject.getDataDescription(dataObject!).label).to.eql('Health');
8888
});
8989
});
9090

9191
describe('which for DA elements', () => {
9292
it('returns the description defined in IEC 61850-7-3', async function () {
9393
const dataObject = validSCL.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="q"]');
94-
94+
9595
expect(nsdocsObject.getDataDescription(dataObject!).label).to.eql('Some DA description');
9696
});
97-
97+
9898
it('returns the name in case no description can be found in IEC 61850-7-3', async function () {
9999
const dataObject = validSCL.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="t"]');
100-
100+
101101
expect(nsdocsObject.getDataDescription(dataObject!).label).to.eql('t');
102102
});
103-
103+
104104
it('returns the description defined in IEC 61850-8-1', async function () {
105105
const dataObject = validSCL.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="SBOw"]');
106-
106+
107107
expect(nsdocsObject.getDataDescription(dataObject!).label).to.eql('Some SBOw title');
108108
});
109-
109+
110110
it('which returns the name in case no description can be found in IEC 61850-8-1', async function () {
111111
const dataObject = validSCL.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="SBO"]');
112-
112+
113113
expect(nsdocsObject.getDataDescription(dataObject!).label).to.eql('SBO');
114114
});
115115
});
@@ -118,31 +118,39 @@ describe('nsdoc', () => {
118118
it('returns the description defined in IEC 61850-7-3', async function () {
119119
const bdaElement = validSCL.querySelector('DAType[id="AnalogueValue_i"] > BDA[name="i"]');
120120
const bdaElementParent = validSCL.querySelector('DOType[id="DummySAV"] > DA[name="instMag"]');
121-
121+
122122
expect(nsdocsObject.getDataDescription(bdaElement!, [bdaElementParent!]).label).to.eql('Some i description');
123123
});
124-
124+
125125
it('returns the name in case no description can be found in IEC 61850-7-3', async function () {
126126
const bdaElement = validSCL.querySelector('DAType[id="AnalogueValue_i"] > BDA[name="x"]');
127127
const bdaElementParent = validSCL.querySelector('DOType[id="DummySAV"] > DA[name="instMag"]');
128-
128+
129129
expect(nsdocsObject.getDataDescription(bdaElement!, [bdaElementParent!]).label).to.eql('x');
130130
});
131-
131+
132132
it('returns the description defined in IEC 61850-8-1', async function () {
133133
const bdaElement = validSCL.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="ctlNum"]');
134134
const bdaElementParent = validSCL.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="SBOw"]');
135-
135+
136136
expect(nsdocsObject.getDataDescription(bdaElement!, [bdaElementParent!]).label).to.eql('Some ctlNum description');
137137
});
138-
138+
139139
it('returns the name in case no description can be found in IEC 61850-8-1', async function () {
140140
const bdaElement = validSCL.querySelector('DAType[id="Dummy.LLN0.Mod.SBOw"] > BDA[name="T"]');
141141
const bdaElementParent = validSCL.querySelector('DOType[id="Dummy.LLN0.Mod"] > DA[name="SBOw"]');
142-
142+
143143
expect(nsdocsObject.getDataDescription(bdaElement!, [bdaElementParent!]).label).to.eql('T');
144144
});
145145
});
146146
});
147147
});
148-
});
148+
});
149+
150+
export function cleanLocalStorageForNsdocFiles() {
151+
// Cleanup NSDoc Files from LocalStorage
152+
localStorage.removeItem('IEC 61850-7-2');
153+
localStorage.removeItem('IEC 61850-7-3');
154+
localStorage.removeItem('IEC 61850-7-4');
155+
localStorage.removeItem('IEC 61850-8-1');
156+
}

0 commit comments

Comments
 (0)