11import { 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' ;
54
65import { TextField } from '@material/mwc-textfield' ;
76
8- describe ( 'PluggingElement ' , ( ) => {
9- let element : MockCompasPlugger ;
7+ describe ( 'CompasOpenSCD-Plugin ' , ( ) => {
8+ let element : MockCompasOpenSCD ;
109 let doc : XMLDocument ;
10+ const docName = 'testDoc' ;
1111
1212 afterEach ( async ( ) => {
1313 await new Promise ( resolve => setTimeout ( resolve , 50 ) ) ; // await animation
@@ -17,14 +17,11 @@ describe('PluggingElement', () => {
1717 doc = await fetch ( '/test/testfiles/valid2007B4.scd' )
1818 . then ( response => response . text ( ) )
1919 . 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+ ) ;
2825 await element . updateComplete ;
2926 } ) ;
3027
@@ -37,19 +34,19 @@ describe('PluggingElement', () => {
3734 let primaryAction : HTMLElement ;
3835
3936 beforeEach ( async ( ) => {
40- element . pluginUI . show ( ) ;
41- await element . pluginUI . updateComplete ;
37+ element . layout . pluginUI . show ( ) ;
38+ await element . layout . pluginUI . updateComplete ;
4239 firstEditorPlugin = < HTMLElement > (
43- element . pluginList . querySelector (
40+ element . layout . pluginList . querySelector (
4441 'mwc-check-list-item:not([noninteractive])'
4542 )
4643 ) ;
4744
4845 resetAction = < HTMLElement > (
49- element . pluginUI . querySelector ( 'mwc-button[slot="secondaryAction"]' )
46+ element . layout . pluginUI . querySelector ( 'mwc-button[slot="secondaryAction"]' )
5047 ) ;
5148 primaryAction = < HTMLElement > (
52- element . pluginUI . querySelector ( 'mwc-button[slot="primaryAction"]' )
49+ element . layout . pluginUI . querySelector ( 'mwc-button[slot="primaryAction"]' )
5350 ) ;
5451 } ) ;
5552
@@ -60,25 +57,25 @@ describe('PluggingElement', () => {
6057 } ) ;
6158
6259 it ( 'enables selected plugins' , async ( ) => {
63- ( < HTMLElement > element . pluginList . firstElementChild ) . click ( ) ;
60+ ( < HTMLElement > element . layout . pluginList . firstElementChild ) . click ( ) ;
6461 await element . updateComplete ;
65- ( < HTMLElement > element . pluginList . firstElementChild ) . click ( ) ;
62+ ( < HTMLElement > element . layout . pluginList . firstElementChild ) . click ( ) ;
6663 await element . updateComplete ;
67- expect ( element ) . property ( 'editors' ) . to . have . lengthOf ( 9 ) ;
64+ expect ( element . layout ) . property ( 'editors' ) . to . have . lengthOf ( 9 ) ;
6865 } ) ;
6966
7067 it ( 'resets plugins to default on reset button click' , async ( ) => {
71- ( < HTMLElement > element . pluginList . firstElementChild ) . click ( ) ;
68+ ( < HTMLElement > element . layout . pluginList . firstElementChild ) . click ( ) ;
7269 await element . updateComplete ;
7370 resetAction . click ( ) ;
7471 await element . updateComplete ;
75- expect ( element ) . property ( 'editors' ) . to . have . lengthOf ( 9 ) ;
72+ expect ( element . layout ) . property ( 'editors' ) . to . have . lengthOf ( 9 ) ;
7673 } ) ;
7774
7875 it ( 'opens the custom plugin dialog on add button click' , async ( ) => {
7976 primaryAction . click ( ) ;
8077 await element . updateComplete ;
81- expect ( element )
78+ expect ( element . layout )
8279 . property ( 'pluginDownloadUI' )
8380 . to . have . property ( 'open' , true ) ;
8481 } ) ;
@@ -93,50 +90,51 @@ describe('PluggingElement', () => {
9390
9491 beforeEach ( async ( ) => {
9592 src = < TextField > (
96- element . pluginDownloadUI . querySelector ( '#pluginSrcInput' )
93+ element . layout . pluginDownloadUI . querySelector ( '#pluginSrcInput' )
9794 ) ;
9895 name = < TextField > (
99- element . pluginDownloadUI . querySelector ( '#pluginNameInput' )
96+ element . layout . pluginDownloadUI . querySelector ( '#pluginNameInput' )
10097 ) ;
10198 primaryAction = < HTMLElement > (
102- element . pluginDownloadUI . querySelector (
99+ element . layout . pluginDownloadUI . querySelector (
103100 'mwc-button[slot="primaryAction"]'
104101 )
105102 ) ;
106- element . pluginDownloadUI . show ( ) ;
107- await element . pluginDownloadUI . updateComplete ;
103+ element . layout . pluginDownloadUI . show ( ) ;
104+ await element . layout . pluginDownloadUI . updateComplete ;
105+ await element . updateComplete ;
108106 menuKindOption = < HTMLElement > (
109- element . pluginDownloadUI . querySelector (
107+ element . layout . pluginDownloadUI . querySelector (
110108 '#pluginKindList > mwc-radio-list-item[id="menu"]'
111109 )
112110 ) ;
113111 validatorKindOption = < HTMLElement > (
114- element . pluginDownloadUI . querySelector (
112+ element . layout . pluginDownloadUI . querySelector (
115113 '#pluginKindList > mwc-radio-list-item[id="validator"]'
116114 )
117115 ) ;
118116 } ) ;
119117
120118 it ( 'requires a name and a valid URL to add a plugin' , async ( ) => {
121119 primaryAction . click ( ) ;
122- expect ( element . pluginDownloadUI ) . to . have . property ( 'open' , true ) ;
120+ expect ( element . layout . pluginDownloadUI ) . to . have . property ( 'open' , true ) ;
123121
124122 src . value = 'http://example.com/plugin.js' ;
125123 await src . updateComplete ;
126124 primaryAction . click ( ) ;
127- expect ( element . pluginDownloadUI ) . to . have . property ( 'open' , true ) ;
125+ expect ( element . layout . pluginDownloadUI ) . to . have . property ( 'open' , true ) ;
128126
129127 src . value = 'notaURL' ;
130128 name . value = 'testName' ;
131129 await src . updateComplete ;
132130 await name . updateComplete ;
133131 primaryAction . click ( ) ;
134- expect ( element . pluginDownloadUI ) . to . have . property ( 'open' , true ) ;
132+ expect ( element . layout . pluginDownloadUI ) . to . have . property ( 'open' , true ) ;
135133
136134 src . value = 'http://example.com/plugin.js' ;
137135 await src . updateComplete ;
138136 primaryAction . click ( ) ;
139- expect ( element . pluginDownloadUI ) . to . have . property ( 'open' , false ) ;
137+ expect ( element . layout . pluginDownloadUI ) . to . have . property ( 'open' , false ) ;
140138 } ) ;
141139
142140 it ( 'adds a new editor kind plugin on add button click' , async ( ) => {
@@ -146,18 +144,18 @@ describe('PluggingElement', () => {
146144 await name . updateComplete ;
147145 primaryAction . click ( ) ;
148146 await element . updateComplete ;
149- expect ( element . editors ) . to . have . lengthOf ( 10 ) ;
147+ expect ( element . layout . editors ) . to . have . lengthOf ( 10 ) ;
150148 } ) ;
151149 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 ;
153151 src . value = 'http://example.com/plugin.js' ;
154152 name . value = 'testName' ;
155153 menuKindOption . click ( ) ;
156154 await src . updateComplete ;
157155 await name . updateComplete ;
158156 primaryAction . click ( ) ;
159157 await element . updateComplete ;
160- expect ( element . menuEntries ) . to . have . lengthOf ( lengthMenuKindPlugins + 1 ) ;
158+ expect ( element . layout . menuEntries ) . to . have . lengthOf ( lengthMenuKindPlugins + 1 ) ;
161159 } ) ;
162160 it ( 'sets requireDoc and position for new menu kind plugin' , async ( ) => {
163161 src . value = 'http://example.com/plugin.js' ;
@@ -169,22 +167,22 @@ describe('PluggingElement', () => {
169167 await element . updateComplete ;
170168
171169 expect (
172- element . menuEntries [ element . menuEntries . length - 1 ]
170+ element . layout . menuEntries [ element . layout . menuEntries . length - 1 ]
173171 ) . to . have . property ( 'requireDoc' ) ;
174172 expect (
175- element . menuEntries [ element . menuEntries . length - 1 ]
173+ element . layout . menuEntries [ element . layout . menuEntries . length - 1 ]
176174 ) . to . have . property ( 'position' ) ;
177175 } ) ;
178176 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 ) ;
180178 src . value = 'http://example.com/plugin.js' ;
181179 name . value = 'testName' ;
182180 validatorKindOption . click ( ) ;
183181 await src . updateComplete ;
184182 await name . updateComplete ;
185183 primaryAction . click ( ) ;
186184 await element . updateComplete ;
187- expect ( element . validators ) . to . have . lengthOf ( 3 ) ;
185+ expect ( element . layout . validators ) . to . have . lengthOf ( 3 ) ;
188186 } ) ;
189187 } ) ;
190188} ) ;
0 commit comments