Skip to content

Commit 0328f56

Browse files
Fixed snapshot test
1 parent 06b4a3a commit 0328f56

File tree

2 files changed

+157
-181
lines changed

2 files changed

+157
-181
lines changed

test/unit/compas/CompasSettings.test.ts

Lines changed: 135 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import {expect, fixture, html} from '@open-wc/testing';
1+
import { expect, fixture, html } from '@open-wc/testing';
22

3-
import "../../../src/compas/CompasSettings.js";
4-
import {CompasSettings, CompasSettingsElement} from "../../../src/compas/CompasSettings.js";
3+
import '../../../src/compas/CompasSettings.js';
4+
import {
5+
CompasSettings,
6+
CompasSettingsElement,
7+
} from '../../../src/compas/CompasSettings.js';
58

69
describe('compas-settings', () => {
710
let element: CompasSettingsElement;
@@ -10,55 +13,129 @@ describe('compas-settings', () => {
1013
localStorage.clear();
1114

1215
element = <CompasSettingsElement>(
13-
await fixture(
14-
html`<compas-settings></compas-settings>`
15-
)
16+
await fixture(html`<compas-settings></compas-settings>`)
1617
);
1718
});
1819

1920
it('initially has default settings', () => {
20-
expect(element).to.have.deep.property('compasSettings', CompasSettings().defaultSettings);
21+
expect(element).to.have.deep.property(
22+
'compasSettings',
23+
CompasSettings().defaultSettings
24+
);
2125
});
2226

2327
it('stores settings to localStorage', () => {
24-
CompasSettings().setCompasSetting('sclDataServiceUrl', 'http://localhost:9090/compas-scl-data-service');
25-
CompasSettings().setCompasSetting('cimMappingServiceUrl', 'http://localhost:9091/compas-cim-mapping');
26-
CompasSettings().setCompasSetting('sclAutoAlignmentServiceUrl', 'http://localhost:9092/compas-scl-auto-alignment');
28+
CompasSettings().setCompasSetting(
29+
'sclDataServiceUrl',
30+
'http://localhost:9090/compas-scl-data-service'
31+
);
32+
CompasSettings().setCompasSetting(
33+
'cimMappingServiceUrl',
34+
'http://localhost:9091/compas-cim-mapping'
35+
);
36+
CompasSettings().setCompasSetting(
37+
'sclAutoAlignmentServiceUrl',
38+
'http://localhost:9092/compas-scl-auto-alignment'
39+
);
2740
CompasSettings().setCompasSetting('useWebsockets', 'off');
28-
expect(localStorage.getItem('sclDataServiceUrl')).to.equal('http://localhost:9090/compas-scl-data-service');
29-
expect(localStorage.getItem('cimMappingServiceUrl')).to.equal('http://localhost:9091/compas-cim-mapping');
30-
expect(localStorage.getItem('sclAutoAlignmentServiceUrl')).to.equal('http://localhost:9092/compas-scl-auto-alignment');
41+
CompasSettings().setCompasSetting(
42+
'sitipeServiceUrl',
43+
'http://localhost:9090/compas-sitipe-service'
44+
);
45+
expect(localStorage.getItem('sclDataServiceUrl')).to.equal(
46+
'http://localhost:9090/compas-scl-data-service'
47+
);
48+
expect(localStorage.getItem('cimMappingServiceUrl')).to.equal(
49+
'http://localhost:9091/compas-cim-mapping'
50+
);
51+
expect(localStorage.getItem('sclAutoAlignmentServiceUrl')).to.equal(
52+
'http://localhost:9092/compas-scl-auto-alignment'
53+
);
3154
expect(localStorage.getItem('useWebsockets')).to.equal('off');
55+
expect(localStorage.getItem('sitipeServiceUrl')).to.equal(
56+
'http://localhost:9090/compas-sitipe-service'
57+
);
3258
});
3359

3460
it('retrieves settings from localStorage', () => {
35-
localStorage.setItem('sclDataServiceUrl', 'http://localhost:9090/compas-scl-data-service');
36-
localStorage.setItem('cimMappingServiceUrl', 'http://localhost:9091/compas-cim-mapping');
37-
localStorage.setItem('sclAutoAlignmentServiceUrl', 'http://localhost:9092/compas-scl-auto-alignment');
61+
localStorage.setItem(
62+
'sclDataServiceUrl',
63+
'http://localhost:9090/compas-scl-data-service'
64+
);
65+
localStorage.setItem(
66+
'cimMappingServiceUrl',
67+
'http://localhost:9091/compas-cim-mapping'
68+
);
69+
localStorage.setItem(
70+
'sclAutoAlignmentServiceUrl',
71+
'http://localhost:9092/compas-scl-auto-alignment'
72+
);
3873
localStorage.setItem('useWebsockets', 'off');
39-
expect(CompasSettings().compasSettings).to.have.property('sclDataServiceUrl', 'http://localhost:9090/compas-scl-data-service');
40-
expect(CompasSettings().compasSettings).to.have.property('cimMappingServiceUrl', 'http://localhost:9091/compas-cim-mapping');
41-
expect(CompasSettings().compasSettings).to.have.property('sclAutoAlignmentServiceUrl', 'http://localhost:9092/compas-scl-auto-alignment');
42-
expect(CompasSettings().compasSettings).to.have.property('useWebsockets', 'off');
74+
75+
localStorage.setItem(
76+
'sitipeServiceUrl',
77+
'http://localhost:9090/compas-sitipe-service'
78+
);
79+
80+
expect(CompasSettings().compasSettings).to.have.property(
81+
'sclDataServiceUrl',
82+
'http://localhost:9090/compas-scl-data-service'
83+
);
84+
expect(CompasSettings().compasSettings).to.have.property(
85+
'cimMappingServiceUrl',
86+
'http://localhost:9091/compas-cim-mapping'
87+
);
88+
expect(CompasSettings().compasSettings).to.have.property(
89+
'sclAutoAlignmentServiceUrl',
90+
'http://localhost:9092/compas-scl-auto-alignment'
91+
);
92+
expect(CompasSettings().compasSettings).to.have.property(
93+
'useWebsockets',
94+
'off'
95+
);
96+
expect(CompasSettings().compasSettings).to.have.property(
97+
'sitipeServiceUrl',
98+
'http://localhost:9090/compas-sitipe-service'
99+
);
43100
});
44101

45102
it('saves chosen settings on save button click', async () => {
46103
await element.updateComplete;
47104

48-
element.getSclDataServiceUrlField().value = 'http://localhost:9091/compas-scl-data-service';
49-
element.getCimMappingServiceUrlField().value = 'http://localhost:9092/compas-cim-mapping';
50-
element.getSclAutoAlignmentServiceUrlField().value = 'http://localhost:9093/compas-scl-auto-alignment';
105+
element.getSclDataServiceUrlField().value =
106+
'http://localhost:9091/compas-scl-data-service';
107+
element.getCimMappingServiceUrlField().value =
108+
'http://localhost:9092/compas-cim-mapping';
109+
element.getSclAutoAlignmentServiceUrlField().value =
110+
'http://localhost:9093/compas-scl-auto-alignment';
51111
element.getUseWebsockets().checked = false;
112+
element.getSitipeServiceUrlField().value =
113+
'http://localhost:9090/compas-sitipe-service';
114+
52115
await element.getSclDataServiceUrlField().updateComplete;
53116
await element.getCimMappingServiceUrlField().updateComplete;
54117
await element.getSclAutoAlignmentServiceUrlField().updateComplete;
55118
await element.getUseWebsockets().updateComplete;
119+
await element.getSitipeServiceUrlField().updateComplete;
56120

57121
expect(element.save()).to.be.true;
58-
expect(element.compasSettings).to.have.property('sclDataServiceUrl', 'http://localhost:9091/compas-scl-data-service');
59-
expect(element.compasSettings).to.have.property('cimMappingServiceUrl', 'http://localhost:9092/compas-cim-mapping');
60-
expect(element.compasSettings).to.have.property('sclAutoAlignmentServiceUrl', 'http://localhost:9093/compas-scl-auto-alignment');
122+
expect(element.compasSettings).to.have.property(
123+
'sclDataServiceUrl',
124+
'http://localhost:9091/compas-scl-data-service'
125+
);
126+
expect(element.compasSettings).to.have.property(
127+
'cimMappingServiceUrl',
128+
'http://localhost:9092/compas-cim-mapping'
129+
);
130+
expect(element.compasSettings).to.have.property(
131+
'sclAutoAlignmentServiceUrl',
132+
'http://localhost:9093/compas-scl-auto-alignment'
133+
);
61134
expect(element.compasSettings).to.have.property('useWebsockets', 'off');
135+
expect(element.compasSettings).to.have.property(
136+
'sitipeServiceUrl',
137+
'http://localhost:9090/compas-sitipe-service'
138+
);
62139
});
63140

64141
it('save will not be done when invalid value (Scl Data Service)', async () => {
@@ -67,7 +144,10 @@ describe('compas-settings', () => {
67144
await element.getSclDataServiceUrlField().updateComplete;
68145

69146
expect(element.save()).to.be.false;
70-
expect(element).to.have.deep.property('compasSettings', CompasSettings().defaultSettings);
147+
expect(element).to.have.deep.property(
148+
'compasSettings',
149+
CompasSettings().defaultSettings
150+
);
71151
});
72152

73153
it('save will not be done when invalid value (CIM Mapping Service)', async () => {
@@ -76,7 +156,10 @@ describe('compas-settings', () => {
76156
await element.getCimMappingServiceUrlField().updateComplete;
77157

78158
expect(element.save()).to.be.false;
79-
expect(element).to.have.deep.property('compasSettings', CompasSettings().defaultSettings);
159+
expect(element).to.have.deep.property(
160+
'compasSettings',
161+
CompasSettings().defaultSettings
162+
);
80163
});
81164

82165
it('save will not be done when invalid value (SCL Auto Alignment Service)', async () => {
@@ -85,19 +168,37 @@ describe('compas-settings', () => {
85168
await element.getSclAutoAlignmentServiceUrlField().updateComplete;
86169

87170
expect(element.save()).to.be.false;
88-
expect(element).to.have.deep.property('compasSettings', CompasSettings().defaultSettings);
171+
expect(element).to.have.deep.property(
172+
'compasSettings',
173+
CompasSettings().defaultSettings
174+
);
89175
});
90176

91177
it('resets settings to default on reset button click', async () => {
92178
await element.updateComplete;
93-
CompasSettings().setCompasSetting('sclDataServiceUrl', 'http://localhost:9091/compas-scl-data-service');
94-
CompasSettings().setCompasSetting('cimMappingServiceUrl', 'http://localhost:9092/compas-cim-mapping');
95-
CompasSettings().setCompasSetting('sclAutoAlignmentServiceUrl', 'http://localhost:9093/compas-scl-auto-alignment');
179+
CompasSettings().setCompasSetting(
180+
'sclDataServiceUrl',
181+
'http://localhost:9091/compas-scl-data-service'
182+
);
183+
CompasSettings().setCompasSetting(
184+
'cimMappingServiceUrl',
185+
'http://localhost:9092/compas-cim-mapping'
186+
);
187+
CompasSettings().setCompasSetting(
188+
'sclAutoAlignmentServiceUrl',
189+
'http://localhost:9093/compas-scl-auto-alignment'
190+
);
96191
CompasSettings().setCompasSetting('useWebsockets', 'off');
97192

98-
expect(element).to.not.have.deep.property('compasSettings', CompasSettings().defaultSettings);
193+
expect(element).to.not.have.deep.property(
194+
'compasSettings',
195+
CompasSettings().defaultSettings
196+
);
99197
expect(element.reset()).to.be.true;
100-
expect(element).to.have.deep.property('compasSettings', CompasSettings().defaultSettings);
198+
expect(element).to.have.deep.property(
199+
'compasSettings',
200+
CompasSettings().defaultSettings
201+
);
101202
});
102203

103204
it('looks like the latest snapshot', async () => {

0 commit comments

Comments
 (0)