1
1
import { expect , fixture , html } from '@open-wc/testing' ;
2
-
3
- import './mock-compas-plugger.js' ;
4
- import { MockCompasPlugger } from './mock-compas-plugger.js' ;
2
+ '../mock-compas-open-scd.js' ;
3
+ import { MockCompasOpenSCD } from '../mock-compas-open-scd.js' ;
5
4
6
5
import { TextField } from '@material/mwc-textfield' ;
7
6
8
- describe ( 'PluggingElement ' , ( ) => {
9
- let element : MockCompasPlugger ;
7
+ describe ( 'CompasOpenSCD-Plugin ' , ( ) => {
8
+ let element : MockCompasOpenSCD ;
10
9
let doc : XMLDocument ;
10
+ const docName = 'testDoc' ;
11
11
12
12
afterEach ( async ( ) => {
13
13
await new Promise ( resolve => setTimeout ( resolve , 50 ) ) ; // await animation
@@ -17,14 +17,11 @@ describe('PluggingElement', () => {
17
17
doc = await fetch ( '/test/testfiles/valid2007B4.scd' )
18
18
. then ( response => response . text ( ) )
19
19
. then ( str => new DOMParser ( ) . parseFromString ( str , 'application/xml' ) ) ;
20
- element = < MockCompasPlugger > (
21
- await fixture (
22
- html `< mock-compas-plugger
23
- .doc =${ doc }
24
- docName ="testDoc"
25
- > </ mock-compas-plugger > `
26
- )
27
- ) ;
20
+ element = < MockCompasOpenSCD > (
21
+ await fixture (
22
+ html `< mock-compas-open-scd .doc =${ doc } .docName =${ docName } > </ mock-compas-open-scd > `
23
+ )
24
+ ) ;
28
25
await element . updateComplete ;
29
26
} ) ;
30
27
@@ -37,19 +34,19 @@ describe('PluggingElement', () => {
37
34
let primaryAction : HTMLElement ;
38
35
39
36
beforeEach ( async ( ) => {
40
- element . pluginUI . show ( ) ;
41
- await element . pluginUI . updateComplete ;
37
+ element . layout . pluginUI . show ( ) ;
38
+ await element . layout . pluginUI . updateComplete ;
42
39
firstEditorPlugin = < HTMLElement > (
43
- element . pluginList . querySelector (
40
+ element . layout . pluginList . querySelector (
44
41
'mwc-check-list-item:not([noninteractive])'
45
42
)
46
43
) ;
47
44
48
45
resetAction = < HTMLElement > (
49
- element . pluginUI . querySelector ( 'mwc-button[slot="secondaryAction"]' )
46
+ element . layout . pluginUI . querySelector ( 'mwc-button[slot="secondaryAction"]' )
50
47
) ;
51
48
primaryAction = < HTMLElement > (
52
- element . pluginUI . querySelector ( 'mwc-button[slot="primaryAction"]' )
49
+ element . layout . pluginUI . querySelector ( 'mwc-button[slot="primaryAction"]' )
53
50
) ;
54
51
} ) ;
55
52
@@ -60,25 +57,25 @@ describe('PluggingElement', () => {
60
57
} ) ;
61
58
62
59
it ( 'enables selected plugins' , async ( ) => {
63
- ( < HTMLElement > element . pluginList . firstElementChild ) . click ( ) ;
60
+ ( < HTMLElement > element . layout . pluginList . firstElementChild ) . click ( ) ;
64
61
await element . updateComplete ;
65
- ( < HTMLElement > element . pluginList . firstElementChild ) . click ( ) ;
62
+ ( < HTMLElement > element . layout . pluginList . firstElementChild ) . click ( ) ;
66
63
await element . updateComplete ;
67
- expect ( element ) . property ( 'editors' ) . to . have . lengthOf ( 9 ) ;
64
+ expect ( element . layout ) . property ( 'editors' ) . to . have . lengthOf ( 9 ) ;
68
65
} ) ;
69
66
70
67
it ( 'resets plugins to default on reset button click' , async ( ) => {
71
- ( < HTMLElement > element . pluginList . firstElementChild ) . click ( ) ;
68
+ ( < HTMLElement > element . layout . pluginList . firstElementChild ) . click ( ) ;
72
69
await element . updateComplete ;
73
70
resetAction . click ( ) ;
74
71
await element . updateComplete ;
75
- expect ( element ) . property ( 'editors' ) . to . have . lengthOf ( 9 ) ;
72
+ expect ( element . layout ) . property ( 'editors' ) . to . have . lengthOf ( 9 ) ;
76
73
} ) ;
77
74
78
75
it ( 'opens the custom plugin dialog on add button click' , async ( ) => {
79
76
primaryAction . click ( ) ;
80
77
await element . updateComplete ;
81
- expect ( element )
78
+ expect ( element . layout )
82
79
. property ( 'pluginDownloadUI' )
83
80
. to . have . property ( 'open' , true ) ;
84
81
} ) ;
@@ -93,50 +90,51 @@ describe('PluggingElement', () => {
93
90
94
91
beforeEach ( async ( ) => {
95
92
src = < TextField > (
96
- element . pluginDownloadUI . querySelector ( '#pluginSrcInput' )
93
+ element . layout . pluginDownloadUI . querySelector ( '#pluginSrcInput' )
97
94
) ;
98
95
name = < TextField > (
99
- element . pluginDownloadUI . querySelector ( '#pluginNameInput' )
96
+ element . layout . pluginDownloadUI . querySelector ( '#pluginNameInput' )
100
97
) ;
101
98
primaryAction = < HTMLElement > (
102
- element . pluginDownloadUI . querySelector (
99
+ element . layout . pluginDownloadUI . querySelector (
103
100
'mwc-button[slot="primaryAction"]'
104
101
)
105
102
) ;
106
- element . pluginDownloadUI . show ( ) ;
107
- await element . pluginDownloadUI . updateComplete ;
103
+ element . layout . pluginDownloadUI . show ( ) ;
104
+ await element . layout . pluginDownloadUI . updateComplete ;
105
+ await element . updateComplete ;
108
106
menuKindOption = < HTMLElement > (
109
- element . pluginDownloadUI . querySelector (
107
+ element . layout . pluginDownloadUI . querySelector (
110
108
'#pluginKindList > mwc-radio-list-item[id="menu"]'
111
109
)
112
110
) ;
113
111
validatorKindOption = < HTMLElement > (
114
- element . pluginDownloadUI . querySelector (
112
+ element . layout . pluginDownloadUI . querySelector (
115
113
'#pluginKindList > mwc-radio-list-item[id="validator"]'
116
114
)
117
115
) ;
118
116
} ) ;
119
117
120
118
it ( 'requires a name and a valid URL to add a plugin' , async ( ) => {
121
119
primaryAction . click ( ) ;
122
- expect ( element . pluginDownloadUI ) . to . have . property ( 'open' , true ) ;
120
+ expect ( element . layout . pluginDownloadUI ) . to . have . property ( 'open' , true ) ;
123
121
124
122
src . value = 'http://example.com/plugin.js' ;
125
123
await src . updateComplete ;
126
124
primaryAction . click ( ) ;
127
- expect ( element . pluginDownloadUI ) . to . have . property ( 'open' , true ) ;
125
+ expect ( element . layout . pluginDownloadUI ) . to . have . property ( 'open' , true ) ;
128
126
129
127
src . value = 'notaURL' ;
130
128
name . value = 'testName' ;
131
129
await src . updateComplete ;
132
130
await name . updateComplete ;
133
131
primaryAction . click ( ) ;
134
- expect ( element . pluginDownloadUI ) . to . have . property ( 'open' , true ) ;
132
+ expect ( element . layout . pluginDownloadUI ) . to . have . property ( 'open' , true ) ;
135
133
136
134
src . value = 'http://example.com/plugin.js' ;
137
135
await src . updateComplete ;
138
136
primaryAction . click ( ) ;
139
- expect ( element . pluginDownloadUI ) . to . have . property ( 'open' , false ) ;
137
+ expect ( element . layout . pluginDownloadUI ) . to . have . property ( 'open' , false ) ;
140
138
} ) ;
141
139
142
140
it ( 'adds a new editor kind plugin on add button click' , async ( ) => {
@@ -146,18 +144,18 @@ describe('PluggingElement', () => {
146
144
await name . updateComplete ;
147
145
primaryAction . click ( ) ;
148
146
await element . updateComplete ;
149
- expect ( element . editors ) . to . have . lengthOf ( 10 ) ;
147
+ expect ( element . layout . editors ) . to . have . lengthOf ( 10 ) ;
150
148
} ) ;
151
149
it ( 'adds a new menu kind plugin on add button click' , async ( ) => {
152
- const lengthMenuKindPlugins = element . menuEntries . length ;
150
+ const lengthMenuKindPlugins = element . layout . menuEntries . length ;
153
151
src . value = 'http://example.com/plugin.js' ;
154
152
name . value = 'testName' ;
155
153
menuKindOption . click ( ) ;
156
154
await src . updateComplete ;
157
155
await name . updateComplete ;
158
156
primaryAction . click ( ) ;
159
157
await element . updateComplete ;
160
- expect ( element . menuEntries ) . to . have . lengthOf ( lengthMenuKindPlugins + 1 ) ;
158
+ expect ( element . layout . menuEntries ) . to . have . lengthOf ( lengthMenuKindPlugins + 1 ) ;
161
159
} ) ;
162
160
it ( 'sets requireDoc and position for new menu kind plugin' , async ( ) => {
163
161
src . value = 'http://example.com/plugin.js' ;
@@ -169,22 +167,22 @@ describe('PluggingElement', () => {
169
167
await element . updateComplete ;
170
168
171
169
expect (
172
- element . menuEntries [ element . menuEntries . length - 1 ]
170
+ element . layout . menuEntries [ element . layout . menuEntries . length - 1 ]
173
171
) . to . have . property ( 'requireDoc' ) ;
174
172
expect (
175
- element . menuEntries [ element . menuEntries . length - 1 ]
173
+ element . layout . menuEntries [ element . layout . menuEntries . length - 1 ]
176
174
) . to . have . property ( 'position' ) ;
177
175
} ) ;
178
176
it ( 'adds a new validator kind plugin on add button click' , async ( ) => {
179
- expect ( element . validators ) . to . have . lengthOf ( 2 ) ;
177
+ expect ( element . layout . validators ) . to . have . lengthOf ( 2 ) ;
180
178
src . value = 'http://example.com/plugin.js' ;
181
179
name . value = 'testName' ;
182
180
validatorKindOption . click ( ) ;
183
181
await src . updateComplete ;
184
182
await name . updateComplete ;
185
183
primaryAction . click ( ) ;
186
184
await element . updateComplete ;
187
- expect ( element . validators ) . to . have . lengthOf ( 3 ) ;
185
+ expect ( element . layout . validators ) . to . have . lengthOf ( 3 ) ;
188
186
} ) ;
189
187
} ) ;
190
188
} ) ;
0 commit comments