kempo-ui 0.0.36 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/components/Table.js +2 -1
- package/src/components/tableControls/PageSelect.js +20 -28
- package/tests/components/Accordion.browser-test.js +470 -0
- package/tests/components/Card.browser-test.js +286 -0
- package/tests/components/ColorPicker.browser-test.js +658 -0
- package/tests/components/ContentSlider.browser-test.js +495 -0
- package/tests/components/Dialog.browser-test.js +677 -0
- package/tests/components/FocusCapture.browser-test.js +187 -0
- package/tests/components/HybridComponent.browser-test.js +1 -1
- package/tests/components/Icon.browser-test.js +355 -0
- package/tests/components/Import.browser-test.js +312 -0
- package/tests/components/PhotoViewer.browser-test.js +640 -0
- package/tests/components/Resize.browser-test.js +553 -0
- package/tests/components/ShadowComponent.browser-test.js +3 -3
- package/tests/components/ShowMore.browser-test.js +618 -0
- package/tests/components/SideMenu.browser-test.js +667 -0
- package/tests/components/Sortable.browser-test.js +650 -0
- package/tests/components/Split.browser-test.js +629 -0
- package/tests/components/Table.browser-test.js +1119 -0
- package/tests/components/Tabs.browser-test.js +847 -0
- package/tests/components/Tags.browser-test.js +604 -0
- package/tests/components/ThemeSwitcher.browser-test.js +413 -0
- package/tests/components/Timestamp.browser-test.js +509 -0
- package/tests/components/Toast.browser-test.js +616 -0
- package/tests/components/Toggle.browser-test.js +557 -0
- package/tests/components/Tree.browser-test.js +790 -0
- package/tests/components/tableControls/ExportControls.browser-test.js +307 -0
- package/tests/components/tableControls/FieldSortHide.browser-test.js +347 -0
- package/tests/components/tableControls/Filters.browser-test.js +376 -0
- package/tests/components/tableControls/HiddenCount.browser-test.js +263 -0
- package/tests/components/tableControls/PaginationControls.browser-test.js +514 -0
- package/tests/components/tableControls/RecordControls.browser-test.js +360 -0
- package/tests/components/tableControls/Search.browser-test.js +283 -0
- package/tests/components/tableControls/TableControl.browser-test.js +300 -0
- package/tests/utils/context.test.js +224 -0
- package/tests/utils/cookie.browser-test.js +146 -0
- package/tests/utils/drag.browser-test.js +285 -0
- package/tests/utils/formatTimestamp.test.js +224 -0
- package/tests/utils/object.browser-test.js +378 -0
- package/tests/utils/propConverters.test.js +207 -0
- package/tests/utils/string.test.js +379 -0
- package/tests/utils/theme.browser-test.js +177 -0
- package/tests/utils/type.test.js +211 -0
- package/tests/utils/wait.browser-test.js +19 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kempo-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Lit based web-component library",
|
|
6
6
|
"main": "index.js",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
"terser": "^5.43.1"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"kempo-css": "^1.0
|
|
33
|
+
"kempo-css": "^1.2.0"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/components/Table.js
CHANGED
|
@@ -885,7 +885,8 @@ export default class Table extends ShadowComponent {
|
|
|
885
885
|
|
|
886
886
|
removeAllFilters() {
|
|
887
887
|
if (this.filters.length) {
|
|
888
|
-
|
|
888
|
+
// Copy array to avoid mutation during iteration
|
|
889
|
+
[...this.filters].forEach(({ field, condition, value }) => {
|
|
889
890
|
this.removeFilter(field, condition, value, false);
|
|
890
891
|
});
|
|
891
892
|
this.requestUpdate();
|
|
@@ -3,17 +3,13 @@ import { html, css } from '../../lit-all.min.js';
|
|
|
3
3
|
|
|
4
4
|
export default class PageSelect extends TableControl {
|
|
5
5
|
static properties = {
|
|
6
|
-
...TableControl.properties
|
|
7
|
-
currentPage: { type: Number, state: true },
|
|
8
|
-
totalPages: { type: Number, state: true }
|
|
6
|
+
...TableControl.properties
|
|
9
7
|
};
|
|
10
8
|
|
|
11
9
|
constructor() {
|
|
12
10
|
super({
|
|
13
11
|
maxWidth: null
|
|
14
12
|
});
|
|
15
|
-
this.currentPage = 1;
|
|
16
|
-
this.totalPages = 1;
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
/*
|
|
@@ -22,17 +18,16 @@ export default class PageSelect extends TableControl {
|
|
|
22
18
|
|
|
23
19
|
connectedCallback() {
|
|
24
20
|
super.connectedCallback();
|
|
25
|
-
this.onTableEvent('pageChange', this.
|
|
26
|
-
this.onTableEvent('pageSizeChange', this.handlePageSizeChange);
|
|
27
|
-
this.onTableEvent('pageCountChanged', this.handlePageCountChange);
|
|
21
|
+
this.onTableEvent('pageChange pageSizeChange pageCountChanged recordsSet', this.handleTableUpdate);
|
|
28
22
|
}
|
|
29
23
|
|
|
30
24
|
disconnectedCallback() {
|
|
31
25
|
super.disconnectedCallback();
|
|
32
26
|
if(this.table){
|
|
33
|
-
this.table.removeEventListener('pageChange', this.
|
|
34
|
-
this.table.removeEventListener('pageSizeChange', this.
|
|
35
|
-
this.table.removeEventListener('pageCountChanged', this.
|
|
27
|
+
this.table.removeEventListener('pageChange', this.handleTableUpdate);
|
|
28
|
+
this.table.removeEventListener('pageSizeChange', this.handleTableUpdate);
|
|
29
|
+
this.table.removeEventListener('pageCountChanged', this.handleTableUpdate);
|
|
30
|
+
this.table.removeEventListener('recordsSet', this.handleTableUpdate);
|
|
36
31
|
}
|
|
37
32
|
}
|
|
38
33
|
|
|
@@ -40,23 +35,8 @@ export default class PageSelect extends TableControl {
|
|
|
40
35
|
Event Handlers
|
|
41
36
|
*/
|
|
42
37
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this.currentPage = this.table.getCurrentPage();
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
handlePageSizeChange = () => {
|
|
50
|
-
if(this.table){
|
|
51
|
-
this.currentPage = this.table.getCurrentPage();
|
|
52
|
-
this.totalPages = this.table.getTotalPages();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
handlePageCountChange = () => {
|
|
57
|
-
if(this.table){
|
|
58
|
-
this.totalPages = this.table.getTotalPages();
|
|
59
|
-
}
|
|
38
|
+
handleTableUpdate = () => {
|
|
39
|
+
this.requestUpdate();
|
|
60
40
|
};
|
|
61
41
|
|
|
62
42
|
handleSelectChange = e => {
|
|
@@ -65,6 +45,18 @@ export default class PageSelect extends TableControl {
|
|
|
65
45
|
}
|
|
66
46
|
};
|
|
67
47
|
|
|
48
|
+
/*
|
|
49
|
+
Getters
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
get currentPage() {
|
|
53
|
+
return this.table ? this.table.getCurrentPage() : 1;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get totalPages() {
|
|
57
|
+
return this.table ? this.table.getTotalPages() : 1;
|
|
58
|
+
}
|
|
59
|
+
|
|
68
60
|
/*
|
|
69
61
|
Rendering Logic
|
|
70
62
|
*/
|
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import Accordion, { AccordionHeader, AccordionPanel } from '../../src/components/Accordion.js';
|
|
2
|
+
|
|
3
|
+
const createAccordion = async (options = {}) => {
|
|
4
|
+
const container = document.createElement('div');
|
|
5
|
+
container.innerHTML = `
|
|
6
|
+
<k-accordion ${options.multiple ? 'multiple' : ''} ${options.persistentId ? `persistent-id="${options.persistentId}"` : ''}>
|
|
7
|
+
<k-accordion-header for-panel="panel1">Header 1</k-accordion-header>
|
|
8
|
+
<k-accordion-panel name="panel1">Content 1</k-accordion-panel>
|
|
9
|
+
<k-accordion-header for-panel="panel2">Header 2</k-accordion-header>
|
|
10
|
+
<k-accordion-panel name="panel2">Content 2</k-accordion-panel>
|
|
11
|
+
<k-accordion-header for-panel="panel3">Header 3</k-accordion-header>
|
|
12
|
+
<k-accordion-panel name="panel3">Content 3</k-accordion-panel>
|
|
13
|
+
</k-accordion>
|
|
14
|
+
`;
|
|
15
|
+
document.body.appendChild(container);
|
|
16
|
+
|
|
17
|
+
const accordion = container.querySelector('k-accordion');
|
|
18
|
+
await accordion.updateComplete;
|
|
19
|
+
|
|
20
|
+
return { container, accordion };
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const cleanup = (container) => {
|
|
24
|
+
if(container && container.parentNode){
|
|
25
|
+
container.parentNode.removeChild(container);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
/*
|
|
31
|
+
Accordion Component Tests
|
|
32
|
+
*/
|
|
33
|
+
'should create accordion element': async ({pass, fail}) => {
|
|
34
|
+
const { container, accordion } = await createAccordion();
|
|
35
|
+
|
|
36
|
+
if(!accordion){
|
|
37
|
+
cleanup(container);
|
|
38
|
+
fail('Accordion element should be created');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if(!(accordion instanceof Accordion)){
|
|
43
|
+
cleanup(container);
|
|
44
|
+
fail('Element should be instance of Accordion');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
cleanup(container);
|
|
49
|
+
pass('Accordion element created correctly');
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
'should have default multiple property as false': async ({pass, fail}) => {
|
|
53
|
+
const { container, accordion } = await createAccordion();
|
|
54
|
+
|
|
55
|
+
if(accordion.multiple !== false){
|
|
56
|
+
cleanup(container);
|
|
57
|
+
fail(`Expected multiple to be false, got ${accordion.multiple}`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
cleanup(container);
|
|
62
|
+
pass('Default multiple property is false');
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
'should have multiple property when attribute is set': async ({pass, fail}) => {
|
|
66
|
+
const { container, accordion } = await createAccordion({ multiple: true });
|
|
67
|
+
|
|
68
|
+
if(accordion.multiple !== true){
|
|
69
|
+
cleanup(container);
|
|
70
|
+
fail(`Expected multiple to be true, got ${accordion.multiple}`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
cleanup(container);
|
|
75
|
+
pass('Multiple property is true when attribute set');
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
'should get header by panel name': async ({pass, fail}) => {
|
|
79
|
+
const { container, accordion } = await createAccordion();
|
|
80
|
+
|
|
81
|
+
const header = accordion.getHeader('panel1');
|
|
82
|
+
if(!header){
|
|
83
|
+
cleanup(container);
|
|
84
|
+
fail('getHeader should return header element');
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if(header.forPanel !== 'panel1'){
|
|
89
|
+
cleanup(container);
|
|
90
|
+
fail(`Expected forPanel "panel1", got "${header.forPanel}"`);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
cleanup(container);
|
|
95
|
+
pass('getHeader returns correct header');
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
'should get panel by name': async ({pass, fail}) => {
|
|
99
|
+
const { container, accordion } = await createAccordion();
|
|
100
|
+
|
|
101
|
+
const panel = accordion.getPanel('panel2');
|
|
102
|
+
if(!panel){
|
|
103
|
+
cleanup(container);
|
|
104
|
+
fail('getPanel should return panel element');
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if(panel.name !== 'panel2'){
|
|
109
|
+
cleanup(container);
|
|
110
|
+
fail(`Expected panel name "panel2", got "${panel.name}"`);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
cleanup(container);
|
|
115
|
+
pass('getPanel returns correct panel');
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
'should open panel': async ({pass, fail}) => {
|
|
119
|
+
const { container, accordion } = await createAccordion();
|
|
120
|
+
|
|
121
|
+
accordion.openPanel('panel1');
|
|
122
|
+
await accordion.updateComplete;
|
|
123
|
+
|
|
124
|
+
const panel = accordion.getPanel('panel1');
|
|
125
|
+
if(!panel.active){
|
|
126
|
+
cleanup(container);
|
|
127
|
+
fail('Panel should be active after openPanel');
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const header = accordion.getHeader('panel1');
|
|
132
|
+
if(!header.active){
|
|
133
|
+
cleanup(container);
|
|
134
|
+
fail('Header should be active after openPanel');
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
cleanup(container);
|
|
139
|
+
pass('openPanel activates panel and header');
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
'should close panel': async ({pass, fail}) => {
|
|
143
|
+
const { container, accordion } = await createAccordion();
|
|
144
|
+
|
|
145
|
+
accordion.openPanel('panel1');
|
|
146
|
+
await accordion.updateComplete;
|
|
147
|
+
|
|
148
|
+
accordion.closePanel('panel1');
|
|
149
|
+
await accordion.updateComplete;
|
|
150
|
+
|
|
151
|
+
const panel = accordion.getPanel('panel1');
|
|
152
|
+
if(panel.active){
|
|
153
|
+
cleanup(container);
|
|
154
|
+
fail('Panel should not be active after closePanel');
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
cleanup(container);
|
|
159
|
+
pass('closePanel deactivates panel');
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
'should toggle panel': async ({pass, fail}) => {
|
|
163
|
+
const { container, accordion } = await createAccordion();
|
|
164
|
+
|
|
165
|
+
accordion.togglePanel('panel1');
|
|
166
|
+
await accordion.updateComplete;
|
|
167
|
+
|
|
168
|
+
let panel = accordion.getPanel('panel1');
|
|
169
|
+
if(!panel.active){
|
|
170
|
+
cleanup(container);
|
|
171
|
+
fail('Panel should be active after first toggle');
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
accordion.togglePanel('panel1');
|
|
176
|
+
await accordion.updateComplete;
|
|
177
|
+
|
|
178
|
+
if(panel.active){
|
|
179
|
+
cleanup(container);
|
|
180
|
+
fail('Panel should not be active after second toggle');
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
cleanup(container);
|
|
185
|
+
pass('togglePanel correctly toggles panel state');
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
'should close other panels in exclusive mode': async ({pass, fail}) => {
|
|
189
|
+
const { container, accordion } = await createAccordion();
|
|
190
|
+
|
|
191
|
+
accordion.openPanel('panel1');
|
|
192
|
+
await accordion.updateComplete;
|
|
193
|
+
|
|
194
|
+
accordion.openPanel('panel2');
|
|
195
|
+
await accordion.updateComplete;
|
|
196
|
+
|
|
197
|
+
const panel1 = accordion.getPanel('panel1');
|
|
198
|
+
const panel2 = accordion.getPanel('panel2');
|
|
199
|
+
|
|
200
|
+
if(panel1.active){
|
|
201
|
+
cleanup(container);
|
|
202
|
+
fail('Panel1 should be closed in exclusive mode');
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if(!panel2.active){
|
|
207
|
+
cleanup(container);
|
|
208
|
+
fail('Panel2 should be open');
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
cleanup(container);
|
|
213
|
+
pass('Exclusive mode closes other panels');
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
'should allow multiple panels open in multiple mode': async ({pass, fail}) => {
|
|
217
|
+
const { container, accordion } = await createAccordion({ multiple: true });
|
|
218
|
+
|
|
219
|
+
accordion.openPanel('panel1');
|
|
220
|
+
await accordion.updateComplete;
|
|
221
|
+
|
|
222
|
+
accordion.openPanel('panel2');
|
|
223
|
+
await accordion.updateComplete;
|
|
224
|
+
|
|
225
|
+
const panel1 = accordion.getPanel('panel1');
|
|
226
|
+
const panel2 = accordion.getPanel('panel2');
|
|
227
|
+
|
|
228
|
+
if(!panel1.active){
|
|
229
|
+
cleanup(container);
|
|
230
|
+
fail('Panel1 should stay open in multiple mode');
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if(!panel2.active){
|
|
235
|
+
cleanup(container);
|
|
236
|
+
fail('Panel2 should be open');
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
cleanup(container);
|
|
241
|
+
pass('Multiple mode allows multiple panels open');
|
|
242
|
+
},
|
|
243
|
+
|
|
244
|
+
'should dispatch openpanel event': async ({pass, fail}) => {
|
|
245
|
+
const { container, accordion } = await createAccordion();
|
|
246
|
+
|
|
247
|
+
let eventFired = false;
|
|
248
|
+
let eventDetail = null;
|
|
249
|
+
accordion.addEventListener('openpanel', (e) => {
|
|
250
|
+
eventFired = true;
|
|
251
|
+
eventDetail = e.detail;
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
accordion.openPanel('panel1');
|
|
255
|
+
await accordion.updateComplete;
|
|
256
|
+
|
|
257
|
+
if(!eventFired){
|
|
258
|
+
cleanup(container);
|
|
259
|
+
fail('openpanel event should be dispatched');
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if(eventDetail.panelName !== 'panel1'){
|
|
264
|
+
cleanup(container);
|
|
265
|
+
fail(`Expected panelName "panel1", got "${eventDetail.panelName}"`);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
cleanup(container);
|
|
270
|
+
pass('openpanel event dispatched with correct detail');
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
'should dispatch closepanel event': async ({pass, fail}) => {
|
|
274
|
+
const { container, accordion } = await createAccordion();
|
|
275
|
+
|
|
276
|
+
accordion.openPanel('panel1');
|
|
277
|
+
await accordion.updateComplete;
|
|
278
|
+
|
|
279
|
+
let eventFired = false;
|
|
280
|
+
let eventDetail = null;
|
|
281
|
+
accordion.addEventListener('closepanel', (e) => {
|
|
282
|
+
eventFired = true;
|
|
283
|
+
eventDetail = e.detail;
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
accordion.closePanel('panel1');
|
|
287
|
+
await accordion.updateComplete;
|
|
288
|
+
|
|
289
|
+
if(!eventFired){
|
|
290
|
+
cleanup(container);
|
|
291
|
+
fail('closepanel event should be dispatched');
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if(eventDetail.panelName !== 'panel1'){
|
|
296
|
+
cleanup(container);
|
|
297
|
+
fail(`Expected panelName "panel1", got "${eventDetail.panelName}"`);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
cleanup(container);
|
|
302
|
+
pass('closepanel event dispatched with correct detail');
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
'should dispatch togglepanel event': async ({pass, fail}) => {
|
|
306
|
+
const { container, accordion } = await createAccordion();
|
|
307
|
+
|
|
308
|
+
let eventFired = false;
|
|
309
|
+
accordion.addEventListener('togglepanel', () => {
|
|
310
|
+
eventFired = true;
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
accordion.togglePanel('panel1');
|
|
314
|
+
await accordion.updateComplete;
|
|
315
|
+
|
|
316
|
+
if(!eventFired){
|
|
317
|
+
cleanup(container);
|
|
318
|
+
fail('togglepanel event should be dispatched');
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
cleanup(container);
|
|
323
|
+
pass('togglepanel event dispatched');
|
|
324
|
+
},
|
|
325
|
+
|
|
326
|
+
/*
|
|
327
|
+
AccordionHeader Tests
|
|
328
|
+
*/
|
|
329
|
+
'AccordionHeader: should have forPanel property': async ({pass, fail}) => {
|
|
330
|
+
const { container, accordion } = await createAccordion();
|
|
331
|
+
|
|
332
|
+
const header = accordion.getHeader('panel1');
|
|
333
|
+
if(header.forPanel !== 'panel1'){
|
|
334
|
+
cleanup(container);
|
|
335
|
+
fail(`Expected forPanel "panel1", got "${header.forPanel}"`);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
cleanup(container);
|
|
340
|
+
pass('AccordionHeader has correct forPanel property');
|
|
341
|
+
},
|
|
342
|
+
|
|
343
|
+
'AccordionHeader: should toggle panel on click': async ({pass, fail}) => {
|
|
344
|
+
const { container, accordion } = await createAccordion();
|
|
345
|
+
|
|
346
|
+
const header = accordion.getHeader('panel1');
|
|
347
|
+
const panel = accordion.getPanel('panel1');
|
|
348
|
+
|
|
349
|
+
header.click();
|
|
350
|
+
await accordion.updateComplete;
|
|
351
|
+
|
|
352
|
+
if(!panel.active){
|
|
353
|
+
cleanup(container);
|
|
354
|
+
fail('Panel should be active after header click');
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
cleanup(container);
|
|
359
|
+
pass('AccordionHeader toggles panel on click');
|
|
360
|
+
},
|
|
361
|
+
|
|
362
|
+
'AccordionHeader: should have accordion getter': async ({pass, fail}) => {
|
|
363
|
+
const { container, accordion } = await createAccordion();
|
|
364
|
+
|
|
365
|
+
const header = accordion.getHeader('panel1');
|
|
366
|
+
if(header.accordion !== accordion){
|
|
367
|
+
cleanup(container);
|
|
368
|
+
fail('Header accordion getter should return parent accordion');
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
cleanup(container);
|
|
373
|
+
pass('AccordionHeader accordion getter works');
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
'AccordionHeader: should render icon slot': async ({pass, fail}) => {
|
|
377
|
+
const { container, accordion } = await createAccordion();
|
|
378
|
+
|
|
379
|
+
const header = accordion.getHeader('panel1');
|
|
380
|
+
await header.updateComplete;
|
|
381
|
+
|
|
382
|
+
const icon = header.shadowRoot.querySelector('k-icon');
|
|
383
|
+
if(!icon){
|
|
384
|
+
cleanup(container);
|
|
385
|
+
fail('Header should render icon element');
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
cleanup(container);
|
|
390
|
+
pass('AccordionHeader renders icon');
|
|
391
|
+
},
|
|
392
|
+
|
|
393
|
+
/*
|
|
394
|
+
AccordionPanel Tests
|
|
395
|
+
*/
|
|
396
|
+
'AccordionPanel: should have name property': async ({pass, fail}) => {
|
|
397
|
+
const { container, accordion } = await createAccordion();
|
|
398
|
+
|
|
399
|
+
const panel = accordion.getPanel('panel1');
|
|
400
|
+
if(panel.name !== 'panel1'){
|
|
401
|
+
cleanup(container);
|
|
402
|
+
fail(`Expected name "panel1", got "${panel.name}"`);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
cleanup(container);
|
|
407
|
+
pass('AccordionPanel has correct name property');
|
|
408
|
+
},
|
|
409
|
+
|
|
410
|
+
'AccordionPanel: should have accordion getter': async ({pass, fail}) => {
|
|
411
|
+
const { container, accordion } = await createAccordion();
|
|
412
|
+
|
|
413
|
+
const panel = accordion.getPanel('panel1');
|
|
414
|
+
if(panel.accordion !== accordion){
|
|
415
|
+
cleanup(container);
|
|
416
|
+
fail('Panel accordion getter should return parent accordion');
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
cleanup(container);
|
|
421
|
+
pass('AccordionPanel accordion getter works');
|
|
422
|
+
},
|
|
423
|
+
|
|
424
|
+
'AccordionPanel: should have transitioning property': async ({pass, fail}) => {
|
|
425
|
+
const { container, accordion } = await createAccordion();
|
|
426
|
+
|
|
427
|
+
const panel = accordion.getPanel('panel1');
|
|
428
|
+
|
|
429
|
+
if(panel.transitioning !== false){
|
|
430
|
+
cleanup(container);
|
|
431
|
+
fail('Panel transitioning should be false initially');
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
accordion.openPanel('panel1');
|
|
436
|
+
|
|
437
|
+
if(!panel.transitioning){
|
|
438
|
+
cleanup(container);
|
|
439
|
+
fail('Panel transitioning should be true during animation');
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
cleanup(container);
|
|
444
|
+
pass('AccordionPanel transitioning property works');
|
|
445
|
+
},
|
|
446
|
+
|
|
447
|
+
'AccordionPanel: active attribute should reflect state': async ({pass, fail}) => {
|
|
448
|
+
const { container, accordion } = await createAccordion();
|
|
449
|
+
|
|
450
|
+
const panel = accordion.getPanel('panel1');
|
|
451
|
+
|
|
452
|
+
if(panel.hasAttribute('active')){
|
|
453
|
+
cleanup(container);
|
|
454
|
+
fail('Panel should not have active attribute initially');
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
accordion.openPanel('panel1');
|
|
459
|
+
await accordion.updateComplete;
|
|
460
|
+
|
|
461
|
+
if(!panel.hasAttribute('active')){
|
|
462
|
+
cleanup(container);
|
|
463
|
+
fail('Panel should have active attribute after opening');
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
cleanup(container);
|
|
468
|
+
pass('AccordionPanel active attribute reflects state');
|
|
469
|
+
}
|
|
470
|
+
};
|