1
- import { expect , fixture , html } from '@open-wc/testing' ;
1
+ import { expect , fixture , html } from '@open-wc/testing' ;
2
2
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' ;
5
8
6
9
describe ( 'compas-settings' , ( ) => {
7
10
let element : CompasSettingsElement ;
@@ -10,55 +13,129 @@ describe('compas-settings', () => {
10
13
localStorage . clear ( ) ;
11
14
12
15
element = < CompasSettingsElement > (
13
- await fixture (
14
- html `< compas-settings > </ compas-settings > `
15
- )
16
+ await fixture ( html `< compas-settings > </ compas-settings > ` )
16
17
) ;
17
18
} ) ;
18
19
19
20
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
+ ) ;
21
25
} ) ;
22
26
23
27
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
+ ) ;
27
40
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
+ ) ;
31
54
expect ( localStorage . getItem ( 'useWebsockets' ) ) . to . equal ( 'off' ) ;
55
+ expect ( localStorage . getItem ( 'sitipeServiceUrl' ) ) . to . equal (
56
+ 'http://localhost:9090/compas-sitipe-service'
57
+ ) ;
32
58
} ) ;
33
59
34
60
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
+ ) ;
38
73
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
+ ) ;
43
100
} ) ;
44
101
45
102
it ( 'saves chosen settings on save button click' , async ( ) => {
46
103
await element . updateComplete ;
47
104
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' ;
51
111
element . getUseWebsockets ( ) . checked = false ;
112
+ element . getSitipeServiceUrlField ( ) . value =
113
+ 'http://localhost:9090/compas-sitipe-service' ;
114
+
52
115
await element . getSclDataServiceUrlField ( ) . updateComplete ;
53
116
await element . getCimMappingServiceUrlField ( ) . updateComplete ;
54
117
await element . getSclAutoAlignmentServiceUrlField ( ) . updateComplete ;
55
118
await element . getUseWebsockets ( ) . updateComplete ;
119
+ await element . getSitipeServiceUrlField ( ) . updateComplete ;
56
120
57
121
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
+ ) ;
61
134
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
+ ) ;
62
139
} ) ;
63
140
64
141
it ( 'save will not be done when invalid value (Scl Data Service)' , async ( ) => {
@@ -67,7 +144,10 @@ describe('compas-settings', () => {
67
144
await element . getSclDataServiceUrlField ( ) . updateComplete ;
68
145
69
146
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
+ ) ;
71
151
} ) ;
72
152
73
153
it ( 'save will not be done when invalid value (CIM Mapping Service)' , async ( ) => {
@@ -76,7 +156,10 @@ describe('compas-settings', () => {
76
156
await element . getCimMappingServiceUrlField ( ) . updateComplete ;
77
157
78
158
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
+ ) ;
80
163
} ) ;
81
164
82
165
it ( 'save will not be done when invalid value (SCL Auto Alignment Service)' , async ( ) => {
@@ -85,19 +168,37 @@ describe('compas-settings', () => {
85
168
await element . getSclAutoAlignmentServiceUrlField ( ) . updateComplete ;
86
169
87
170
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
+ ) ;
89
175
} ) ;
90
176
91
177
it ( 'resets settings to default on reset button click' , async ( ) => {
92
178
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
+ ) ;
96
191
CompasSettings ( ) . setCompasSetting ( 'useWebsockets' , 'off' ) ;
97
192
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
+ ) ;
99
197
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
+ ) ;
101
202
} ) ;
102
203
103
204
it ( 'looks like the latest snapshot' , async ( ) => {
0 commit comments