@dile/ui 3.18.0 → 3.18.1
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/components/toast/src/DileToast.js +2 -1
- package/components/toast/src/DileToastPersistent.js +1 -1
- package/package.json +4 -4
- package/components/accordion/accordion.spec.js +0 -253
- package/components/app-drawer/app-drawer.spec.js +0 -262
- package/components/avatar/avatar.spec.js +0 -25
- package/components/bottom-nav/__screenshots__/bottom-nav.spec.js/dile-bottom-nav-places-the-sheet-and-the-overlay-above-the-bar-1.png +0 -0
- package/components/bottom-nav/bottom-nav.spec.js +0 -340
- package/components/box-selector/box-selector-item.spec.js +0 -27
- package/components/box-selector/box-selector.spec.js +0 -27
- package/components/breadcrumbs/breadcrumbs-item.spec.js +0 -28
- package/components/breadcrumbs/breadcrumbs.spec.js +0 -33
- package/components/button/button.spec.js +0 -234
- package/components/card/card-slide.spec.js +0 -30
- package/components/card/card.spec.js +0 -26
- package/components/checkbox/checkbox.spec.js +0 -235
- package/components/chip/chip.spec.js +0 -31
- package/components/color-picker/color-picker.spec.js +0 -133
- package/components/confirm/confirm.spec.js +0 -57
- package/components/confirm-text/confirm-text.spec.js +0 -29
- package/components/copy-markdown-url/copy-markdown-url.spec.js +0 -27
- package/components/copy-text/copy-text.spec.js +0 -38
- package/components/data-grid/__screenshots__/data-grid.spec.js/dile-data-grid-dispatches-item-checkbox-changed-and-dile-data-grid-item-selected-when-a-checkbox-is-toggled-1.png +0 -0
- package/components/data-grid/data-grid.spec.js +0 -421
- package/components/drop-file/drop-file.spec.js +0 -214
- package/components/drop-file/file-preview.spec.js +0 -35
- package/components/floating-feedback/floating-feedback.spec.js +0 -30
- package/components/floating-menu/floating-menu-item.spec.js +0 -27
- package/components/floating-menu/floating-menu.spec.js +0 -31
- package/components/form-separator/form-separator.spec.js +0 -28
- package/components/hamburger/hamburger.spec.js +0 -28
- package/components/icon/icon.spec.js +0 -31
- package/components/icon-switch/icon-switch-group.spec.js +0 -46
- package/components/icon-switch/icon-switch.spec.js +0 -35
- package/components/info-box/info-box.spec.js +0 -38
- package/components/inline-feedback/inline-feedback.spec.js +0 -46
- package/components/input/input-contact.spec.js +0 -32
- package/components/input/input-icon.spec.js +0 -166
- package/components/input/input-integer.spec.js +0 -31
- package/components/input/input-mask.spec.js +0 -314
- package/components/input/input-message.spec.js +0 -27
- package/components/input/input-money.spec.js +0 -30
- package/components/input/input-number-mask.spec.js +0 -48
- package/components/input/input-number.spec.js +0 -109
- package/components/input/input-percentage.spec.js +0 -31
- package/components/input/input-search.spec.js +0 -91
- package/components/input/input.spec.js +0 -47
- package/components/light-mode-switch/light-mode-switch.spec.js +0 -34
- package/components/menu-hamburger/menu-hamburger.spec.js +0 -34
- package/components/menu-overlay/menu-overlay.spec.js +0 -44
- package/components/message/message.spec.js +0 -42
- package/components/modal/__screenshots__/modal.spec.js/dile-modal-closes-only-the-topmost-modal-when-Esc-is-pressed-1.png +0 -0
- package/components/modal/__screenshots__/modal.spec.js/dile-modal-dispatches-dile-modal-closed-and-animates-when-the-opened-property-is-set-to-false-1.png +0 -0
- package/components/modal/__screenshots__/modal.spec.js/dile-modal-does-not-close-a-blocking-modal-when-Esc-is-pressed-1.png +0 -0
- package/components/modal/__screenshots__/modal.spec.js/dile-modal-does-not-close-the-modal-below-when-the-topmost-modal-is-blocking-1.png +0 -0
- package/components/modal/__screenshots__/modal.spec.js/dile-modal-ignores-transitionend-events-coming-from-inner-elements-1.png +0 -0
- package/components/modal/__screenshots__/modal.spec.js/dile-modal-keeps-the-focus-on-content-focused-by-the-user-when-opening-1.png +0 -0
- package/components/modal/__screenshots__/modal.spec.js/dile-modal-opens-and-closes-through-the-opened-attribute-1.png +0 -0
- package/components/modal/__screenshots__/modal.spec.js/dile-modal-reflects-the-opened-property-to-the-attribute-1.png +0 -0
- package/components/modal/__screenshots__/modal.spec.js/dile-modal-releases-the-background-layer-after-the-close-animation-even-without-transitionend-1.png +0 -0
- package/components/modal/__screenshots__/modal.spec.js/dile-modal-releases-the-background-layer-immediately-when-the-animation-duration-is-0s-1.png +0 -0
- package/components/modal/modal-help.spec.js +0 -32
- package/components/modal/modal.spec.js +0 -250
- package/components/nav/nav.spec.js +0 -33
- package/components/number-picker/number-picker-element.spec.js +0 -30
- package/components/number-picker/number-picker.spec.js +0 -30
- package/components/order-switch/__screenshots__/order-switch.spec.js/dile-order-switch-clicking-the-label-re-announces-the-current-value-without-toggling-when-not-selected-1.png +0 -0
- package/components/order-switch/__screenshots__/order-switch.spec.js/dile-order-switch-clicking-the-label-toggles-the-order-when-selected-1.png +0 -0
- package/components/order-switch/__screenshots__/order-switch.spec.js/dile-order-switch-defaults-to-ascending-order-1.png +0 -0
- package/components/order-switch/order-switch.spec.js +0 -57
- package/components/otp-input/otp-input.spec.js +0 -41
- package/components/pages/pages.spec.js +0 -44
- package/components/password/password.spec.js +0 -35
- package/components/progress-bar/progress-bar.spec.js +0 -28
- package/components/radio-group/__screenshots__/radio-group-dialog.spec.js/dile-radio-group-dialog-renders-dialog-items-with-labels-and-values-1.png +0 -0
- package/components/radio-group/__screenshots__/radio-group-dialog.spec.js/dile-radio-group-dialog-renders-items-with-optional-description-1.png +0 -0
- package/components/radio-group/__screenshots__/radio-group-dialog.spec.js/dile-radio-group-dialog-updates-value-when-an-option-is-selected-1.png +0 -0
- package/components/radio-group/radio-group-dialog.spec.js +0 -126
- package/components/radio-group/radio-group.spec.js +0 -128
- package/components/radio-group/radio.spec.js +0 -32
- package/components/range/range.spec.js +0 -36
- package/components/rating/rating.spec.js +0 -34
- package/components/rating/star.spec.js +0 -30
- package/components/rating-scale-question/rating-scale-option.spec.js +0 -32
- package/components/rating-scale-question/rating-scale-question.spec.js +0 -35
- package/components/select/__screenshots__/select-search.spec.js/dile-select-search-Value-API-uses-the-label-as-accessible-name-of-the-selected-field-1.png +0 -0
- package/components/select/select-ajax-overlay.spec.js +0 -469
- package/components/select/select-overlay.spec.js +0 -612
- package/components/select/select-search.spec.js +0 -318
- package/components/select/select.spec.js +0 -574
- package/components/selector/selector-item.spec.js +0 -40
- package/components/selector/selector-overlay.spec.js +0 -139
- package/components/selector/selector.spec.js +0 -45
- package/components/slide-menu/slide-menu.spec.js +0 -38
- package/components/slide-show/slide-show.spec.js +0 -34
- package/components/social-icon/social-icon.spec.js +0 -26
- package/components/spinner/spinner-bar.spec.js +0 -26
- package/components/spinner/spinner-block.spec.js +0 -21
- package/components/spinner/spinner-horizontal.spec.js +0 -25
- package/components/spinner/spinner-icon.spec.js +0 -25
- package/components/spinner/spinner-modal.spec.js +0 -26
- package/components/spinner/spinner.spec.js +0 -26
- package/components/steps/steps.spec.js +0 -84
- package/components/switch/switch.spec.js +0 -33
- package/components/tabs/tabs.spec.js +0 -85
- package/components/textarea/textarea.spec.js +0 -39
- package/components/time-picker/time-picker.spec.js +0 -26
- package/components/timer/timer.spec.js +0 -31
- package/components/toast/toast.spec.js +0 -86
- package/components/tooltip/chip-tooltip.spec.js +0 -29
- package/components/tooltip/tooltip.spec.js +0 -32
- package/components/web-visor/web-visor.spec.js +0 -32
- package/mixins/form/src/DileForm.spec.js +0 -29
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import './input-mask.js';
|
|
3
|
-
|
|
4
|
-
describe('dile-input-mask', () => {
|
|
5
|
-
afterEach(() => {
|
|
6
|
-
document.body.innerHTML = '';
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
async function renderInputMask(html) {
|
|
10
|
-
document.body.innerHTML = html;
|
|
11
|
-
const el = document.body.querySelector('dile-input-mask');
|
|
12
|
-
await el.updateComplete;
|
|
13
|
-
return el;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
it('renders a native text input', async () => {
|
|
17
|
-
const el = await renderInputMask('<dile-input-mask name="iban" mask="AA00 0000 0000 0000 0000"></dile-input-mask>');
|
|
18
|
-
expect(el.shadowRoot.querySelector('input')).toBeTruthy();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('masks input with letters and digits', async () => {
|
|
22
|
-
const el = await renderInputMask('<dile-input-mask name="iban" mask="AA00 0000 0000 0000 0000"></dile-input-mask>');
|
|
23
|
-
const input = el.shadowRoot.querySelector('input');
|
|
24
|
-
|
|
25
|
-
const chars = ['E', 'S', '9', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'];
|
|
26
|
-
chars.forEach((char) => {
|
|
27
|
-
const keydownEvent = new KeyboardEvent('keydown', {
|
|
28
|
-
key: char,
|
|
29
|
-
bubbles: true,
|
|
30
|
-
cancelable: true,
|
|
31
|
-
});
|
|
32
|
-
input.dispatchEvent(keydownEvent);
|
|
33
|
-
input.value += char;
|
|
34
|
-
const inputEvent = new Event('input', { bubbles: true });
|
|
35
|
-
input.dispatchEvent(inputEvent);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
await el.updateComplete;
|
|
39
|
-
|
|
40
|
-
expect(el.maskedValue).toBe('ES91 0000 0000 0000 0000');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('validates invalid format on blur', async () => {
|
|
44
|
-
const el = await renderInputMask('<dile-input-mask name="iban" mask="AA00 0000 0000 0000 0000"></dile-input-mask>');
|
|
45
|
-
const input = el.shadowRoot.querySelector('input');
|
|
46
|
-
|
|
47
|
-
// Try to start with a digit instead of a letter
|
|
48
|
-
input.value = '91ES0000000000000000';
|
|
49
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
50
|
-
await el.updateComplete;
|
|
51
|
-
input.dispatchEvent(new Event('blur', { bubbles: true }));
|
|
52
|
-
await el.updateComplete;
|
|
53
|
-
|
|
54
|
-
expect(el.errored).toBe(true);
|
|
55
|
-
expect(el.message).toContain('expected a letter');
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('supports multiple languages for error messages', async () => {
|
|
59
|
-
// English (default)
|
|
60
|
-
const elEn = await renderInputMask('<dile-input-mask name="iban" mask="AA00" language="en"></dile-input-mask>');
|
|
61
|
-
const inputEn = elEn.shadowRoot.querySelector('input');
|
|
62
|
-
inputEn.value = '9100';
|
|
63
|
-
inputEn.dispatchEvent(new Event('input', { bubbles: true }));
|
|
64
|
-
await elEn.updateComplete;
|
|
65
|
-
inputEn.dispatchEvent(new Event('blur', { bubbles: true }));
|
|
66
|
-
await elEn.updateComplete;
|
|
67
|
-
|
|
68
|
-
expect(elEn.message).toContain('expected a letter');
|
|
69
|
-
|
|
70
|
-
// Spanish
|
|
71
|
-
const elEs = await renderInputMask('<dile-input-mask name="iban" mask="AA00" language="es"></dile-input-mask>');
|
|
72
|
-
const inputEs = elEs.shadowRoot.querySelector('input');
|
|
73
|
-
inputEs.value = '9100';
|
|
74
|
-
inputEs.dispatchEvent(new Event('input', { bubbles: true }));
|
|
75
|
-
await elEs.updateComplete;
|
|
76
|
-
inputEs.dispatchEvent(new Event('blur', { bubbles: true }));
|
|
77
|
-
await elEs.updateComplete;
|
|
78
|
-
|
|
79
|
-
expect(elEs.message).toContain('se esperaba una letra');
|
|
80
|
-
|
|
81
|
-
// French
|
|
82
|
-
const elFr = await renderInputMask('<dile-input-mask name="iban" mask="AA00" language="fr"></dile-input-mask>');
|
|
83
|
-
const inputFr = elFr.shadowRoot.querySelector('input');
|
|
84
|
-
inputFr.value = '9100';
|
|
85
|
-
inputFr.dispatchEvent(new Event('input', { bubbles: true }));
|
|
86
|
-
await elFr.updateComplete;
|
|
87
|
-
inputFr.dispatchEvent(new Event('blur', { bubbles: true }));
|
|
88
|
-
await elFr.updateComplete;
|
|
89
|
-
|
|
90
|
-
expect(elFr.message).toContain('lettre attendue');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('allows selecting and replacing characters', async () => {
|
|
94
|
-
const el = await renderInputMask('<dile-input-mask name="iban" mask="AA00 0000"></dile-input-mask>');
|
|
95
|
-
const input = el.shadowRoot.querySelector('input');
|
|
96
|
-
|
|
97
|
-
// First, enter some initial value
|
|
98
|
-
const initialChars = ['E', 'S', '9', '1', '0', '0', '0', '0'];
|
|
99
|
-
initialChars.forEach((char) => {
|
|
100
|
-
input.value += char;
|
|
101
|
-
const inputEvent = new Event('input', { bubbles: true });
|
|
102
|
-
input.dispatchEvent(inputEvent);
|
|
103
|
-
});
|
|
104
|
-
await el.updateComplete;
|
|
105
|
-
|
|
106
|
-
expect(el.maskedValue).toBe('ES91 0000');
|
|
107
|
-
|
|
108
|
-
// Now simulate selecting characters at positions 3-5 (the "91") and replacing with "AB"
|
|
109
|
-
// In the masked value "ES91 0000", positions 3-5 contain "91"
|
|
110
|
-
input.value = 'ESAB 0000';
|
|
111
|
-
input.setSelectionRange(5, 5); // Cursor after the replacement
|
|
112
|
-
const inputEvent = new Event('input', { bubbles: true });
|
|
113
|
-
input.dispatchEvent(inputEvent);
|
|
114
|
-
await el.updateComplete;
|
|
115
|
-
|
|
116
|
-
// Should have replaced with AB and maintained format
|
|
117
|
-
expect(el.value).toContain('ESAB');
|
|
118
|
-
expect(el.maskedValue).toBe('ESAB 0000');
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('does not show error while typing incomplete input', async () => {
|
|
122
|
-
const el = await renderInputMask('<dile-input-mask name="iban" mask="AA00 0000 0000 0000 0000"></dile-input-mask>');
|
|
123
|
-
const input = el.shadowRoot.querySelector('input');
|
|
124
|
-
|
|
125
|
-
// User starts typing correctly
|
|
126
|
-
input.value = 'ES91';
|
|
127
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
128
|
-
await el.updateComplete;
|
|
129
|
-
|
|
130
|
-
expect(el.errored).toBeFalsy();
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('transforms to uppercase when pattern uses A', async () => {
|
|
134
|
-
const el = await renderInputMask('<dile-input-mask name="test" mask="AA00 AA"></dile-input-mask>');
|
|
135
|
-
const input = el.shadowRoot.querySelector('input');
|
|
136
|
-
|
|
137
|
-
// User types lowercase, should transform to uppercase
|
|
138
|
-
const chars = ['e', 's', '9', '1', 'a', 'b'];
|
|
139
|
-
chars.forEach((char) => {
|
|
140
|
-
input.value += char;
|
|
141
|
-
const inputEvent = new Event('input', { bubbles: true });
|
|
142
|
-
input.dispatchEvent(inputEvent);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
await el.updateComplete;
|
|
146
|
-
|
|
147
|
-
expect(el.maskedValue).toBe('ES91 AB');
|
|
148
|
-
expect(el.value).toBe('ES91AB');
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('transforms to lowercase when pattern uses a', async () => {
|
|
152
|
-
const el = await renderInputMask('<dile-input-mask name="test" mask="aa00 aa"></dile-input-mask>');
|
|
153
|
-
const input = el.shadowRoot.querySelector('input');
|
|
154
|
-
|
|
155
|
-
// User types uppercase, should transform to lowercase
|
|
156
|
-
const chars = ['E', 'S', '9', '1', 'A', 'B'];
|
|
157
|
-
chars.forEach((char) => {
|
|
158
|
-
input.value += char;
|
|
159
|
-
const inputEvent = new Event('input', { bubbles: true });
|
|
160
|
-
input.dispatchEvent(inputEvent);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
await el.updateComplete;
|
|
164
|
-
|
|
165
|
-
expect(el.maskedValue).toBe('es91 ab');
|
|
166
|
-
expect(el.value).toBe('es91ab');
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('handles mixed case transformation', async () => {
|
|
170
|
-
const el = await renderInputMask('<dile-input-mask name="test" mask="AA-aa-00"></dile-input-mask>');
|
|
171
|
-
const input = el.shadowRoot.querySelector('input');
|
|
172
|
-
|
|
173
|
-
// User types: first two should be uppercase, next two lowercase, then digits
|
|
174
|
-
const chars = ['a', 'b', 'c', 'd', '1', '2'];
|
|
175
|
-
chars.forEach((char) => {
|
|
176
|
-
input.value += char;
|
|
177
|
-
const inputEvent = new Event('input', { bubbles: true });
|
|
178
|
-
input.dispatchEvent(inputEvent);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
await el.updateComplete;
|
|
182
|
-
|
|
183
|
-
expect(el.maskedValue).toBe('AB-cd-12');
|
|
184
|
-
expect(el.value).toBe('ABcd12');
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('supports X pattern for alphanumeric uppercase', async () => {
|
|
188
|
-
const el = await renderInputMask('<dile-input-mask name="test" mask="XX-0000"></dile-input-mask>');
|
|
189
|
-
const input = el.shadowRoot.querySelector('input');
|
|
190
|
-
|
|
191
|
-
// X accepts both letters and digits
|
|
192
|
-
const chars = ['a', 'B', '1', '2', '3', '4'];
|
|
193
|
-
chars.forEach((char) => {
|
|
194
|
-
input.value += char;
|
|
195
|
-
const inputEvent = new Event('input', { bubbles: true });
|
|
196
|
-
input.dispatchEvent(inputEvent);
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
await el.updateComplete;
|
|
200
|
-
|
|
201
|
-
// Letters should be uppercase, digits unchanged
|
|
202
|
-
expect(el.maskedValue).toBe('AB-1234');
|
|
203
|
-
expect(el.value).toBe('AB1234');
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('supports x pattern for alphanumeric lowercase', async () => {
|
|
207
|
-
const el = await renderInputMask('<dile-input-mask name="test" mask="xx-0000"></dile-input-mask>');
|
|
208
|
-
const input = el.shadowRoot.querySelector('input');
|
|
209
|
-
|
|
210
|
-
// x accepts both letters and digits
|
|
211
|
-
const chars = ['A', 'b', '1', '2', '3', '4'];
|
|
212
|
-
chars.forEach((char) => {
|
|
213
|
-
input.value += char;
|
|
214
|
-
const inputEvent = new Event('input', { bubbles: true });
|
|
215
|
-
input.dispatchEvent(inputEvent);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
await el.updateComplete;
|
|
219
|
-
|
|
220
|
-
// Letters should be lowercase, digits unchanged
|
|
221
|
-
expect(el.maskedValue).toBe('ab-1234');
|
|
222
|
-
expect(el.value).toBe('ab1234');
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
it('applies lazy separators only when next block is filled', async () => {
|
|
226
|
-
const el = await renderInputMask('<dile-input-mask name="iban" mask="AA-XXXX-0000" lazySeparators></dile-input-mask>');
|
|
227
|
-
const input = el.shadowRoot.querySelector('input');
|
|
228
|
-
|
|
229
|
-
// Type 'ES' - should show 'ES' without trailing separator
|
|
230
|
-
input.value = 'ES';
|
|
231
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
232
|
-
await el.updateComplete;
|
|
233
|
-
expect(el.maskedValue).toBe('ES');
|
|
234
|
-
|
|
235
|
-
// Type 'ESW' - should show 'ES-W' (separator added when next block starts)
|
|
236
|
-
input.value = 'ESW';
|
|
237
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
238
|
-
await el.updateComplete;
|
|
239
|
-
expect(el.maskedValue).toBe('ES-W');
|
|
240
|
-
|
|
241
|
-
// Type 'ESWSWQ' - should show 'ES-WSWQ'
|
|
242
|
-
input.value = 'ESWSWQ';
|
|
243
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
244
|
-
await el.updateComplete;
|
|
245
|
-
expect(el.maskedValue).toBe('ES-WSWQ');
|
|
246
|
-
|
|
247
|
-
// Type 'ESWSWQ0' - should show 'ES-WSWQ-0' (separator added when digits block starts)
|
|
248
|
-
input.value = 'ESWSWQ0';
|
|
249
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
250
|
-
await el.updateComplete;
|
|
251
|
-
expect(el.maskedValue).toBe('ES-WSWQ-0');
|
|
252
|
-
|
|
253
|
-
// Type complete 'ESWSWQ0000' - should show 'ES-WSWQ-0000'
|
|
254
|
-
input.value = 'ESWSWQ0000';
|
|
255
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
256
|
-
await el.updateComplete;
|
|
257
|
-
expect(el.maskedValue).toBe('ES-WSWQ-0000');
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
it('uses normal separators by default (lazySeparators=false)', async () => {
|
|
261
|
-
const el = await renderInputMask('<dile-input-mask name="test" mask="AA-XXXX-0000"></dile-input-mask>');
|
|
262
|
-
const input = el.shadowRoot.querySelector('input');
|
|
263
|
-
|
|
264
|
-
// Type 'ES' - should show 'ES-' (separator added immediately)
|
|
265
|
-
input.value = 'ES';
|
|
266
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
267
|
-
await el.updateComplete;
|
|
268
|
-
expect(el.maskedValue).toBe('ES-');
|
|
269
|
-
|
|
270
|
-
// Type 'ESWSWQ0000' - separators already included
|
|
271
|
-
input.value = 'ESWSWQ0000';
|
|
272
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
273
|
-
await el.updateComplete;
|
|
274
|
-
expect(el.maskedValue).toBe('ES-WSWQ-0000');
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it('supports lazySeparators property', async () => {
|
|
278
|
-
const el = await renderInputMask('<dile-input-mask name="test" mask="AA-XXXX-0000" lazySeparators></dile-input-mask>');
|
|
279
|
-
const input = el.shadowRoot.querySelector('input');
|
|
280
|
-
|
|
281
|
-
// Type 'ES' - should show 'ES' without separator (lazy behavior)
|
|
282
|
-
input.value = 'ES';
|
|
283
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
284
|
-
await el.updateComplete;
|
|
285
|
-
expect(el.maskedValue).toBe('ES');
|
|
286
|
-
|
|
287
|
-
// Type 'ESW' - should show 'ES-W' (separator added when next block starts)
|
|
288
|
-
input.value = 'ESW';
|
|
289
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
290
|
-
await el.updateComplete;
|
|
291
|
-
expect(el.maskedValue).toBe('ES-W');
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it('can toggle lazySeparators property dynamically', async () => {
|
|
295
|
-
const el = await renderInputMask('<dile-input-mask name="test" mask="AA-XXXX-0000"></dile-input-mask>');
|
|
296
|
-
const input = el.shadowRoot.querySelector('input');
|
|
297
|
-
|
|
298
|
-
// Initially with normal separators
|
|
299
|
-
input.value = 'ES';
|
|
300
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
301
|
-
await el.updateComplete;
|
|
302
|
-
expect(el.maskedValue).toBe('ES-');
|
|
303
|
-
|
|
304
|
-
// Toggle to lazy separators
|
|
305
|
-
el.lazySeparators = true;
|
|
306
|
-
await el.updateComplete;
|
|
307
|
-
input.value = 'ES';
|
|
308
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
309
|
-
await el.updateComplete;
|
|
310
|
-
expect(el.maskedValue).toBe('ES');
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import './input-message.js';
|
|
3
|
-
|
|
4
|
-
describe('dile-input-message', () => {
|
|
5
|
-
afterEach(() => {
|
|
6
|
-
document.body.innerHTML = '';
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
async function renderInputMessage(html) {
|
|
10
|
-
document.body.innerHTML = html;
|
|
11
|
-
const el = document.body.querySelector('dile-input-message');
|
|
12
|
-
await el.updateComplete;
|
|
13
|
-
return el;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
it('renders nothing when there is no message', async () => {
|
|
17
|
-
const el = await renderInputMessage('<dile-input-message></dile-input-message>');
|
|
18
|
-
expect(el.shadowRoot.querySelector('.message')).toBeNull();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('renders the message text when set', async () => {
|
|
22
|
-
const el = await renderInputMessage('<dile-input-message message="Required"></dile-input-message>');
|
|
23
|
-
const message = el.shadowRoot.querySelector('.message span');
|
|
24
|
-
expect(message).toBeTruthy();
|
|
25
|
-
expect(message.textContent.trim()).toBe('Required');
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import './input-money.js';
|
|
3
|
-
|
|
4
|
-
describe('dile-input-money', () => {
|
|
5
|
-
afterEach(() => {
|
|
6
|
-
document.body.innerHTML = '';
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
async function renderInputMoney(html) {
|
|
10
|
-
document.body.innerHTML = html;
|
|
11
|
-
const el = document.body.querySelector('dile-input-money');
|
|
12
|
-
await el.updateComplete;
|
|
13
|
-
return el;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
it('renders a native text input with the given value', async () => {
|
|
17
|
-
const el = await renderInputMoney('<dile-input-money name="price" value="9.5"></dile-input-money>');
|
|
18
|
-
const input = el.shadowRoot.querySelector('input');
|
|
19
|
-
expect(input).toBeTruthy();
|
|
20
|
-
expect(input.value).toBe('9.5');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('formats the value to two decimals via set()', async () => {
|
|
24
|
-
const el = await renderInputMoney('<dile-input-money name="price"></dile-input-money>');
|
|
25
|
-
el.set('9.5');
|
|
26
|
-
await el.updateComplete;
|
|
27
|
-
|
|
28
|
-
expect(el.value).toBe('9.50');
|
|
29
|
-
});
|
|
30
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import './input-number-mask.js';
|
|
3
|
-
|
|
4
|
-
describe('dile-input-number-mask', () => {
|
|
5
|
-
afterEach(() => {
|
|
6
|
-
document.body.innerHTML = '';
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
async function renderInputNumberMask(html) {
|
|
10
|
-
document.body.innerHTML = html;
|
|
11
|
-
const el = document.body.querySelector('dile-input-number-mask');
|
|
12
|
-
await el.updateComplete;
|
|
13
|
-
return el;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
it('renders a native text input', async () => {
|
|
17
|
-
const el = await renderInputNumberMask('<dile-input-number-mask name="code" mask="00-00"></dile-input-number-mask>');
|
|
18
|
-
expect(el.shadowRoot.querySelector('input')).toBeTruthy();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('masks digit keydowns following the given pattern', async () => {
|
|
22
|
-
const el = await renderInputNumberMask('<dile-input-number-mask name="code" mask="00-00"></dile-input-number-mask>');
|
|
23
|
-
const input = el.shadowRoot.querySelector('input');
|
|
24
|
-
|
|
25
|
-
// Simular el usuario escribiendo números: keydown + input event
|
|
26
|
-
['1', '2', '3'].forEach((key) => {
|
|
27
|
-
// El navegador primero dispara keydown
|
|
28
|
-
const keydownEvent = new KeyboardEvent('keydown', {
|
|
29
|
-
key,
|
|
30
|
-
bubbles: true,
|
|
31
|
-
cancelable: true
|
|
32
|
-
});
|
|
33
|
-
input.dispatchEvent(keydownEvent);
|
|
34
|
-
|
|
35
|
-
// Simular que el navegador actualiza el value del input
|
|
36
|
-
input.value += key;
|
|
37
|
-
|
|
38
|
-
// Luego dispara input event
|
|
39
|
-
const inputEvent = new Event('input', { bubbles: true });
|
|
40
|
-
input.dispatchEvent(inputEvent);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// Esperar a que Lit procese los cambios
|
|
44
|
-
await el.updateComplete;
|
|
45
|
-
|
|
46
|
-
expect(el.maskedValue).toBe('12-3');
|
|
47
|
-
});
|
|
48
|
-
});
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import './input-number.js';
|
|
3
|
-
|
|
4
|
-
describe('dile-input-number', () => {
|
|
5
|
-
afterEach(() => {
|
|
6
|
-
document.body.innerHTML = '';
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
async function renderInputNumber(content) {
|
|
10
|
-
document.body.innerHTML = content;
|
|
11
|
-
const el = document.body.querySelector('dile-input-number');
|
|
12
|
-
await el.updateComplete;
|
|
13
|
-
return el;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
it('normalizes comma separator to dot by default', async () => {
|
|
17
|
-
const el = await renderInputNumber('<dile-input-number name="amount"></dile-input-number>');
|
|
18
|
-
const input = el.shadowRoot.querySelector('input');
|
|
19
|
-
|
|
20
|
-
input.value = '12,75';
|
|
21
|
-
input.dispatchEvent(new Event('input'));
|
|
22
|
-
await el.updateComplete;
|
|
23
|
-
|
|
24
|
-
expect(el.value).toBe('12.75');
|
|
25
|
-
expect(input.value).toBe('12.75');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('normalizes dot separator to comma when configured', async () => {
|
|
29
|
-
const el = await renderInputNumber('<dile-input-number name="amount" decimalSeparator=","></dile-input-number>');
|
|
30
|
-
const input = el.shadowRoot.querySelector('input');
|
|
31
|
-
|
|
32
|
-
input.value = '12.75';
|
|
33
|
-
input.dispatchEvent(new Event('input'));
|
|
34
|
-
await el.updateComplete;
|
|
35
|
-
|
|
36
|
-
expect(el.value).toBe('12.75');
|
|
37
|
-
expect(input.value).toBe('12,75');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('applies min, max and decimals on blur', async () => {
|
|
41
|
-
const el = await renderInputNumber('<dile-input-number name="amount" min="1" max="10" decimals="2"></dile-input-number>');
|
|
42
|
-
const input = el.shadowRoot.querySelector('input');
|
|
43
|
-
|
|
44
|
-
input.value = '10.987';
|
|
45
|
-
input.dispatchEvent(new Event('blur'));
|
|
46
|
-
await el.updateComplete;
|
|
47
|
-
|
|
48
|
-
expect(el.value).toBe('10.00');
|
|
49
|
-
expect(input.value).toBe('10.00');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('applies step rounding and decimal separator formatting on blur', async () => {
|
|
53
|
-
const el = await renderInputNumber('<dile-input-number name="amount" decimalSeparator="," step="0.25" decimals="2"></dile-input-number>');
|
|
54
|
-
const input = el.shadowRoot.querySelector('input');
|
|
55
|
-
|
|
56
|
-
input.value = '1.37';
|
|
57
|
-
input.dispatchEvent(new Event('blur'));
|
|
58
|
-
await el.updateComplete;
|
|
59
|
-
|
|
60
|
-
expect(el.value).toBe('1.25');
|
|
61
|
-
expect(input.value).toBe('1,25');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('normalizes separator only on blur when normalizeOn is blur', async () => {
|
|
65
|
-
const el = await renderInputNumber('<dile-input-number name="amount" decimalSeparator="," normalizeOn="blur"></dile-input-number>');
|
|
66
|
-
const input = el.shadowRoot.querySelector('input');
|
|
67
|
-
|
|
68
|
-
input.dispatchEvent(new Event('focus'));
|
|
69
|
-
input.value = '12.75';
|
|
70
|
-
input.dispatchEvent(new Event('input'));
|
|
71
|
-
await el.updateComplete;
|
|
72
|
-
|
|
73
|
-
expect(el.value).toBe('12.75');
|
|
74
|
-
expect(input.value).toBe('12.75');
|
|
75
|
-
|
|
76
|
-
input.dispatchEvent(new Event('blur'));
|
|
77
|
-
await el.updateComplete;
|
|
78
|
-
|
|
79
|
-
expect(el.value).toBe('12.75');
|
|
80
|
-
expect(input.value).toBe('12,75');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('falls back to input normalization when normalizeOn is invalid', async () => {
|
|
84
|
-
const el = await renderInputNumber('<dile-input-number name="amount" decimalSeparator="," normalizeOn="foo"></dile-input-number>');
|
|
85
|
-
const input = el.shadowRoot.querySelector('input');
|
|
86
|
-
|
|
87
|
-
await el.updateComplete;
|
|
88
|
-
expect(el.normalizeOn).toBe('input');
|
|
89
|
-
|
|
90
|
-
input.value = '12.75';
|
|
91
|
-
input.dispatchEvent(new Event('input'));
|
|
92
|
-
await el.updateComplete;
|
|
93
|
-
|
|
94
|
-
expect(el.value).toBe('12.75');
|
|
95
|
-
expect(input.value).toBe('12,75');
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('keeps canonical value when normalizeOn fallback applies', async () => {
|
|
99
|
-
const el = await renderInputNumber('<dile-input-number name="amount" decimalSeparator="," normalizeOn="foo"></dile-input-number>');
|
|
100
|
-
const input = el.shadowRoot.querySelector('input');
|
|
101
|
-
|
|
102
|
-
input.value = '8,5';
|
|
103
|
-
input.dispatchEvent(new Event('input'));
|
|
104
|
-
await el.updateComplete;
|
|
105
|
-
|
|
106
|
-
expect(el.value).toBe('8.5');
|
|
107
|
-
expect(input.value).toBe('8,5');
|
|
108
|
-
});
|
|
109
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import './input-percentage.js';
|
|
3
|
-
|
|
4
|
-
describe('dile-input-percentage', () => {
|
|
5
|
-
afterEach(() => {
|
|
6
|
-
document.body.innerHTML = '';
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
async function renderInputPercentage(html) {
|
|
10
|
-
document.body.innerHTML = html;
|
|
11
|
-
const el = document.body.querySelector('dile-input-percentage');
|
|
12
|
-
await el.updateComplete;
|
|
13
|
-
return el;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
it('renders a native text input with the given value and a % label', async () => {
|
|
17
|
-
const el = await renderInputPercentage('<dile-input-percentage name="rate" value="10"></dile-input-percentage>');
|
|
18
|
-
const input = el.shadowRoot.querySelector('input');
|
|
19
|
-
expect(input).toBeTruthy();
|
|
20
|
-
expect(input.value).toBe('10');
|
|
21
|
-
expect(el.shadowRoot.querySelector('.labelright').textContent.trim()).toBe('%');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('formats the value as a float via doFormat()', async () => {
|
|
25
|
-
const el = await renderInputPercentage('<dile-input-percentage name="rate" value="10.5"></dile-input-percentage>');
|
|
26
|
-
el.doFormat();
|
|
27
|
-
await el.updateComplete;
|
|
28
|
-
|
|
29
|
-
expect(el.value).toBe(10.5);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import './input-search.js';
|
|
3
|
-
|
|
4
|
-
describe('dile-input-search', () => {
|
|
5
|
-
afterEach(() => {
|
|
6
|
-
document.body.innerHTML = '';
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
async function renderInputSearch(html) {
|
|
10
|
-
document.body.innerHTML = html;
|
|
11
|
-
const el = document.body.querySelector('dile-input-search');
|
|
12
|
-
await el.updateComplete;
|
|
13
|
-
return el;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
it('renders a native search input and a search icon', async () => {
|
|
17
|
-
const el = await renderInputSearch('<dile-input-search placeholder="Search..."></dile-input-search>');
|
|
18
|
-
const input = el.shadowRoot.querySelector('input');
|
|
19
|
-
expect(input).toBeTruthy();
|
|
20
|
-
expect(input.placeholder).toBe('Search...');
|
|
21
|
-
expect(el.shadowRoot.querySelector('dile-icon')).toBeTruthy();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('renders the input as a search field with browser and password manager autofill disabled', async () => {
|
|
25
|
-
const el = await renderInputSearch('<dile-input-search></dile-input-search>');
|
|
26
|
-
const input = el.shadowRoot.querySelector('input');
|
|
27
|
-
expect(input.type).toBe('search');
|
|
28
|
-
expect(input.getAttribute('autocomplete')).toBe('off');
|
|
29
|
-
expect(input.hasAttribute('data-1p-ignore')).toBe(true);
|
|
30
|
-
expect(input.getAttribute('data-lpignore')).toBe('true');
|
|
31
|
-
expect(input.getAttribute('data-form-type')).toBe('other');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('does not show an empty error box when errored without error slot content', async () => {
|
|
35
|
-
const el = await renderInputSearch('<dile-input-search errored></dile-input-search>');
|
|
36
|
-
|
|
37
|
-
const errorMessage = el.shadowRoot.getElementById('error-msg');
|
|
38
|
-
expect(errorMessage.hidden).toBe(true);
|
|
39
|
-
expect(errorMessage.getBoundingClientRect().height).toBe(0);
|
|
40
|
-
// Only the search box itself gets the bordered box styles
|
|
41
|
-
expect(getComputedStyle(errorMessage).borderTopStyle).toBe('none');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('shows the error slot content when errored', async () => {
|
|
45
|
-
const el = await renderInputSearch('<dile-input-search errored><span slot="error">Wrong search</span></dile-input-search>');
|
|
46
|
-
await el.updateComplete;
|
|
47
|
-
|
|
48
|
-
const errorMessage = el.shadowRoot.getElementById('error-msg');
|
|
49
|
-
expect(errorMessage.hidden).toBe(false);
|
|
50
|
-
expect(el.shadowRoot.querySelector('input').getAttribute('aria-describedby')).toBe('error-msg');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('labels the button in English by default, with configurable texts', async () => {
|
|
54
|
-
const el = await renderInputSearch('<dile-input-search></dile-input-search>');
|
|
55
|
-
const button = el.shadowRoot.querySelector('button');
|
|
56
|
-
expect(button.getAttribute('aria-label')).toBe('Search');
|
|
57
|
-
expect(el.shadowRoot.querySelector('input').getAttribute('aria-label')).toBe('Search');
|
|
58
|
-
|
|
59
|
-
el.value = 'lit';
|
|
60
|
-
await el.updateComplete;
|
|
61
|
-
expect(button.getAttribute('aria-label')).toBe('Clear search');
|
|
62
|
-
|
|
63
|
-
el.clearButtonLabel = 'Limpiar búsqueda';
|
|
64
|
-
await el.updateComplete;
|
|
65
|
-
expect(button.getAttribute('aria-label')).toBe('Limpiar búsqueda');
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('uses accessibleLabel as aria-label, falling back to name', async () => {
|
|
69
|
-
const named = await renderInputSearch('<dile-input-search name="Products"></dile-input-search>');
|
|
70
|
-
expect(named.shadowRoot.querySelector('input').getAttribute('aria-label')).toBe('Products');
|
|
71
|
-
|
|
72
|
-
const labelled = await renderInputSearch('<dile-input-search name="Products" accessibleLabel="Search products"></dile-input-search>');
|
|
73
|
-
expect(labelled.shadowRoot.querySelector('input').getAttribute('aria-label')).toBe('Search products');
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('updates the value on input and dispatches dile-input-search after the delay', async () => {
|
|
77
|
-
const el = await renderInputSearch('<dile-input-search delay="10"></dile-input-search>');
|
|
78
|
-
const input = el.shadowRoot.querySelector('input');
|
|
79
|
-
let detail = null;
|
|
80
|
-
el.addEventListener('dile-input-search', (e) => { detail = e.detail; });
|
|
81
|
-
|
|
82
|
-
input.value = 'lit';
|
|
83
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
84
|
-
await el.updateComplete;
|
|
85
|
-
|
|
86
|
-
expect(el.value).toBe('lit');
|
|
87
|
-
|
|
88
|
-
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
89
|
-
expect(detail).toEqual({ keyword: 'lit' });
|
|
90
|
-
});
|
|
91
|
-
});
|