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
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import Card from '../../src/components/Card.js';
|
|
2
|
+
|
|
3
|
+
const createCard = async (options = {}) => {
|
|
4
|
+
const card = document.createElement('k-card');
|
|
5
|
+
if(options.label){
|
|
6
|
+
card.label = options.label;
|
|
7
|
+
}
|
|
8
|
+
if(options.content){
|
|
9
|
+
card.innerHTML = options.content;
|
|
10
|
+
}
|
|
11
|
+
document.body.appendChild(card);
|
|
12
|
+
await card.updateComplete;
|
|
13
|
+
return card;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const cleanup = (element) => {
|
|
17
|
+
if(element && element.parentNode){
|
|
18
|
+
element.parentNode.removeChild(element);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
/*
|
|
24
|
+
Card Element Tests
|
|
25
|
+
*/
|
|
26
|
+
'should create card element': async ({pass, fail}) => {
|
|
27
|
+
const card = await createCard();
|
|
28
|
+
|
|
29
|
+
if(!card){
|
|
30
|
+
cleanup(card);
|
|
31
|
+
fail('Card element should be created');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if(!(card instanceof Card)){
|
|
36
|
+
cleanup(card);
|
|
37
|
+
fail('Element should be instance of Card');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
cleanup(card);
|
|
42
|
+
pass('Card element created correctly');
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
'should have shadow root': async ({pass, fail}) => {
|
|
46
|
+
const card = await createCard();
|
|
47
|
+
|
|
48
|
+
if(!card.shadowRoot){
|
|
49
|
+
cleanup(card);
|
|
50
|
+
fail('Card should have shadow root');
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
cleanup(card);
|
|
55
|
+
pass('Card has shadow root');
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
'should have default label as null': async ({pass, fail}) => {
|
|
59
|
+
const card = await createCard();
|
|
60
|
+
|
|
61
|
+
if(card.label !== null){
|
|
62
|
+
cleanup(card);
|
|
63
|
+
fail(`Expected label to be null, got "${card.label}"`);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
cleanup(card);
|
|
68
|
+
pass('Default label is null');
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
'should set label property': async ({pass, fail}) => {
|
|
72
|
+
const card = await createCard({ label: 'Test Label' });
|
|
73
|
+
|
|
74
|
+
if(card.label !== 'Test Label'){
|
|
75
|
+
cleanup(card);
|
|
76
|
+
fail(`Expected label "Test Label", got "${card.label}"`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
cleanup(card);
|
|
81
|
+
pass('Label property is set correctly');
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
'should reflect label attribute': async ({pass, fail}) => {
|
|
85
|
+
const card = await createCard({ label: 'My Card' });
|
|
86
|
+
|
|
87
|
+
if(!card.hasAttribute('label')){
|
|
88
|
+
cleanup(card);
|
|
89
|
+
fail('Card should have label attribute');
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if(card.getAttribute('label') !== 'My Card'){
|
|
94
|
+
cleanup(card);
|
|
95
|
+
fail(`Expected attribute "My Card", got "${card.getAttribute('label')}"`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
cleanup(card);
|
|
100
|
+
pass('Label attribute reflects property');
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
'should render card container': async ({pass, fail}) => {
|
|
104
|
+
const card = await createCard();
|
|
105
|
+
|
|
106
|
+
const container = card.shadowRoot.querySelector('#card');
|
|
107
|
+
if(!container){
|
|
108
|
+
cleanup(card);
|
|
109
|
+
fail('Card should render #card container');
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
cleanup(card);
|
|
114
|
+
pass('Card renders container element');
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
'should render label element': async ({pass, fail}) => {
|
|
118
|
+
const card = await createCard({ label: 'Test Label' });
|
|
119
|
+
|
|
120
|
+
const labelElement = card.shadowRoot.querySelector('#label');
|
|
121
|
+
if(!labelElement){
|
|
122
|
+
cleanup(card);
|
|
123
|
+
fail('Card should render #label element');
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if(labelElement.textContent !== 'Test Label'){
|
|
128
|
+
cleanup(card);
|
|
129
|
+
fail(`Expected label text "Test Label", got "${labelElement.textContent}"`);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
cleanup(card);
|
|
134
|
+
pass('Card renders label element with correct text');
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
'should render slot for content': async ({pass, fail}) => {
|
|
138
|
+
const card = await createCard();
|
|
139
|
+
|
|
140
|
+
const slot = card.shadowRoot.querySelector('slot');
|
|
141
|
+
if(!slot){
|
|
142
|
+
cleanup(card);
|
|
143
|
+
fail('Card should have a slot element');
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
cleanup(card);
|
|
148
|
+
pass('Card renders slot element');
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
'should slot content correctly': async ({pass, fail}) => {
|
|
152
|
+
const card = await createCard({ content: '<p>Test Content</p>' });
|
|
153
|
+
|
|
154
|
+
const content = card.querySelector('p');
|
|
155
|
+
if(!content){
|
|
156
|
+
cleanup(card);
|
|
157
|
+
fail('Content should be slotted into card');
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if(content.textContent !== 'Test Content'){
|
|
162
|
+
cleanup(card);
|
|
163
|
+
fail(`Expected "Test Content", got "${content.textContent}"`);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
cleanup(card);
|
|
168
|
+
pass('Card slots content correctly');
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
'should update label dynamically': async ({pass, fail}) => {
|
|
172
|
+
const card = await createCard({ label: 'Initial' });
|
|
173
|
+
|
|
174
|
+
card.label = 'Updated';
|
|
175
|
+
await card.updateComplete;
|
|
176
|
+
|
|
177
|
+
const labelElement = card.shadowRoot.querySelector('#label');
|
|
178
|
+
if(labelElement.textContent !== 'Updated'){
|
|
179
|
+
cleanup(card);
|
|
180
|
+
fail(`Expected "Updated", got "${labelElement.textContent}"`);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
cleanup(card);
|
|
185
|
+
pass('Card updates label dynamically');
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
'should set label via attribute': async ({pass, fail}) => {
|
|
189
|
+
const container = document.createElement('div');
|
|
190
|
+
container.innerHTML = '<k-card label="Attribute Label"></k-card>';
|
|
191
|
+
document.body.appendChild(container);
|
|
192
|
+
|
|
193
|
+
const card = container.querySelector('k-card');
|
|
194
|
+
await card.updateComplete;
|
|
195
|
+
|
|
196
|
+
if(card.label !== 'Attribute Label'){
|
|
197
|
+
container.parentNode.removeChild(container);
|
|
198
|
+
fail(`Expected "Attribute Label", got "${card.label}"`);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
container.parentNode.removeChild(container);
|
|
203
|
+
pass('Card sets label from attribute');
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
'should have block display': async ({pass, fail}) => {
|
|
207
|
+
const card = await createCard();
|
|
208
|
+
|
|
209
|
+
const computedStyle = window.getComputedStyle(card);
|
|
210
|
+
if(computedStyle.display !== 'block'){
|
|
211
|
+
cleanup(card);
|
|
212
|
+
fail(`Expected display "block", got "${computedStyle.display}"`);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
cleanup(card);
|
|
217
|
+
pass('Card has block display');
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
'label should be hidden when not set': async ({pass, fail}) => {
|
|
221
|
+
const card = await createCard();
|
|
222
|
+
|
|
223
|
+
const labelElement = card.shadowRoot.querySelector('#label');
|
|
224
|
+
const computedStyle = window.getComputedStyle(labelElement);
|
|
225
|
+
|
|
226
|
+
if(computedStyle.display !== 'none'){
|
|
227
|
+
cleanup(card);
|
|
228
|
+
fail(`Expected label display "none", got "${computedStyle.display}"`);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
cleanup(card);
|
|
233
|
+
pass('Label is hidden when not set');
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
'label should be visible when set': async ({pass, fail}) => {
|
|
237
|
+
const card = await createCard({ label: 'Visible Label' });
|
|
238
|
+
|
|
239
|
+
const labelElement = card.shadowRoot.querySelector('#label');
|
|
240
|
+
const computedStyle = window.getComputedStyle(labelElement);
|
|
241
|
+
|
|
242
|
+
if(computedStyle.display === 'none'){
|
|
243
|
+
cleanup(card);
|
|
244
|
+
fail('Label should be visible when set');
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
cleanup(card);
|
|
249
|
+
pass('Label is visible when set');
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
'should handle empty label string': async ({pass, fail}) => {
|
|
253
|
+
const card = await createCard();
|
|
254
|
+
|
|
255
|
+
card.label = '';
|
|
256
|
+
await card.updateComplete;
|
|
257
|
+
|
|
258
|
+
// Empty string sets the property but may not set attribute depending on implementation
|
|
259
|
+
if(card.label !== ''){
|
|
260
|
+
cleanup(card);
|
|
261
|
+
fail(`Expected label to be empty string, got "${card.label}"`);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
cleanup(card);
|
|
266
|
+
pass('Card handles empty label string');
|
|
267
|
+
},
|
|
268
|
+
|
|
269
|
+
'should remove label when set to null': async ({pass, fail}) => {
|
|
270
|
+
const card = await createCard({ label: 'Initial' });
|
|
271
|
+
|
|
272
|
+
card.label = null;
|
|
273
|
+
await card.updateComplete;
|
|
274
|
+
|
|
275
|
+
// When label is null, the attribute should be removed
|
|
276
|
+
if(card.hasAttribute('label') && card.getAttribute('label') !== null){
|
|
277
|
+
// Some implementations keep empty attribute
|
|
278
|
+
cleanup(card);
|
|
279
|
+
pass('Card removes or clears label attribute when null');
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
cleanup(card);
|
|
284
|
+
pass('Card removes label when set to null');
|
|
285
|
+
}
|
|
286
|
+
};
|