vueless 1.0.2-beta.24 → 1.0.2-beta.26
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
CHANGED
|
@@ -8,10 +8,8 @@ import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
|
8
8
|
import type { Props } from "../types.ts";
|
|
9
9
|
|
|
10
10
|
describe("UButton.vue", () => {
|
|
11
|
-
// Props tests
|
|
12
11
|
describe("Props", () => {
|
|
13
|
-
|
|
14
|
-
it("applies the correct variant class", async () => {
|
|
12
|
+
it("Variant – applies the correct variant class", async () => {
|
|
15
13
|
const color = "primary";
|
|
16
14
|
const variants = {
|
|
17
15
|
solid: "text-inverted bg-primary",
|
|
@@ -33,8 +31,7 @@ describe("UButton.vue", () => {
|
|
|
33
31
|
});
|
|
34
32
|
});
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
it("applies the correct color class", async () => {
|
|
34
|
+
it("Color – applies the correct color class", async () => {
|
|
38
35
|
const colors = [
|
|
39
36
|
"primary",
|
|
40
37
|
"secondary",
|
|
@@ -58,8 +55,7 @@ describe("UButton.vue", () => {
|
|
|
58
55
|
});
|
|
59
56
|
});
|
|
60
57
|
|
|
61
|
-
|
|
62
|
-
it("applies the correct size class", async () => {
|
|
58
|
+
it("Size – applies the correct size class", async () => {
|
|
63
59
|
const size = {
|
|
64
60
|
"2xs": "text-small",
|
|
65
61
|
xs: "text-small",
|
|
@@ -80,8 +76,7 @@ describe("UButton.vue", () => {
|
|
|
80
76
|
});
|
|
81
77
|
});
|
|
82
78
|
|
|
83
|
-
|
|
84
|
-
it("renders the correct label text", () => {
|
|
79
|
+
it("Label – renders the correct label text", () => {
|
|
85
80
|
const label = "Button";
|
|
86
81
|
|
|
87
82
|
const component = mount(UButton, {
|
|
@@ -93,8 +88,7 @@ describe("UButton.vue", () => {
|
|
|
93
88
|
expect(component.text()).toBe(label);
|
|
94
89
|
});
|
|
95
90
|
|
|
96
|
-
|
|
97
|
-
it("renders the correct HTML tag", () => {
|
|
91
|
+
it("Tag – renders the correct HTML tag", () => {
|
|
98
92
|
const tags = ["button", "a", "div"];
|
|
99
93
|
|
|
100
94
|
tags.forEach((tag) => {
|
|
@@ -108,8 +102,7 @@ describe("UButton.vue", () => {
|
|
|
108
102
|
});
|
|
109
103
|
});
|
|
110
104
|
|
|
111
|
-
|
|
112
|
-
it("renders icon when icon prop is provided", () => {
|
|
105
|
+
it("Icon – renders icon when prop is provided", () => {
|
|
113
106
|
const icon = "close";
|
|
114
107
|
const label = "Button";
|
|
115
108
|
|
|
@@ -127,8 +120,7 @@ describe("UButton.vue", () => {
|
|
|
127
120
|
expect(nestedUIconComponents[0].props("name")).toBe(icon);
|
|
128
121
|
});
|
|
129
122
|
|
|
130
|
-
|
|
131
|
-
it("renders left icon when leftIcon prop is provided", () => {
|
|
123
|
+
it("Left Icon – renders icon when prop is provided", () => {
|
|
132
124
|
const leftIcon = "close";
|
|
133
125
|
const label = "Button";
|
|
134
126
|
|
|
@@ -146,8 +138,7 @@ describe("UButton.vue", () => {
|
|
|
146
138
|
expect(nestedUIconComponents[0].props("name")).toBe(leftIcon);
|
|
147
139
|
});
|
|
148
140
|
|
|
149
|
-
|
|
150
|
-
it("renders right icon when rightIcon prop is provided", () => {
|
|
141
|
+
it("Right Icon – renders icon when prop is provided", () => {
|
|
151
142
|
const rightIcon = "close";
|
|
152
143
|
const label = "Button";
|
|
153
144
|
|
|
@@ -165,8 +156,7 @@ describe("UButton.vue", () => {
|
|
|
165
156
|
expect(nestedUIconComponents[0].props("name")).toBe(rightIcon);
|
|
166
157
|
});
|
|
167
158
|
|
|
168
|
-
|
|
169
|
-
it("applies the correct tabindex attribute", () => {
|
|
159
|
+
it("Tabindex – applies the correct attribute", () => {
|
|
170
160
|
const tabindex = "2";
|
|
171
161
|
|
|
172
162
|
const component = mount(UButton, {
|
|
@@ -178,8 +168,7 @@ describe("UButton.vue", () => {
|
|
|
178
168
|
expect(component.attributes("tabindex")).toBe(tabindex);
|
|
179
169
|
});
|
|
180
170
|
|
|
181
|
-
|
|
182
|
-
it("applies disabled attribute when disabled prop is true", () => {
|
|
171
|
+
it("Disabled – applies attribute when prop is true", () => {
|
|
183
172
|
const disabled = true;
|
|
184
173
|
|
|
185
174
|
const component = mount(UButton, {
|
|
@@ -191,8 +180,7 @@ describe("UButton.vue", () => {
|
|
|
191
180
|
expect(component.attributes("disabled")).toBeDefined();
|
|
192
181
|
});
|
|
193
182
|
|
|
194
|
-
|
|
195
|
-
it("applies block class when block prop is true", () => {
|
|
183
|
+
it("Block – applies class when prop is true", () => {
|
|
196
184
|
const block = true;
|
|
197
185
|
const expectedClass = "w-full";
|
|
198
186
|
|
|
@@ -205,8 +193,7 @@ describe("UButton.vue", () => {
|
|
|
205
193
|
expect(component.attributes("class")).toContain(expectedClass);
|
|
206
194
|
});
|
|
207
195
|
|
|
208
|
-
|
|
209
|
-
it("applies round class when round prop is true", () => {
|
|
196
|
+
it("Round – applies class when prop is true", () => {
|
|
210
197
|
const round = true;
|
|
211
198
|
const expectedClass = "rounded-full";
|
|
212
199
|
|
|
@@ -219,8 +206,7 @@ describe("UButton.vue", () => {
|
|
|
219
206
|
expect(component.attributes("class")).toContain(expectedClass);
|
|
220
207
|
});
|
|
221
208
|
|
|
222
|
-
|
|
223
|
-
it("applies square classes when square prop is true", () => {
|
|
209
|
+
it("Square – applies classes when prop is true", () => {
|
|
224
210
|
const square = true;
|
|
225
211
|
const size = {
|
|
226
212
|
"2xs": "p-1",
|
|
@@ -243,8 +229,7 @@ describe("UButton.vue", () => {
|
|
|
243
229
|
});
|
|
244
230
|
});
|
|
245
231
|
|
|
246
|
-
|
|
247
|
-
it("shows loader when loading prop is true", async () => {
|
|
232
|
+
it("Loading – shows loader when prop is true", async () => {
|
|
248
233
|
const loading = true;
|
|
249
234
|
const label = "Button with some long text";
|
|
250
235
|
const expectedClass = "pointer-events-none";
|
|
@@ -262,8 +247,7 @@ describe("UButton.vue", () => {
|
|
|
262
247
|
expect(component.attributes("class")).toContain(expectedClass); // Unclickable
|
|
263
248
|
});
|
|
264
249
|
|
|
265
|
-
|
|
266
|
-
it("applies the correct id attribute", () => {
|
|
250
|
+
it("Id – applies the correct attribute", () => {
|
|
267
251
|
const id = "test-button-id";
|
|
268
252
|
|
|
269
253
|
const component = mount(UButton, {
|
|
@@ -275,8 +259,7 @@ describe("UButton.vue", () => {
|
|
|
275
259
|
expect(component.attributes("id")).toBe(id);
|
|
276
260
|
});
|
|
277
261
|
|
|
278
|
-
|
|
279
|
-
it("applies the correct data-test attribute", () => {
|
|
262
|
+
it("Data Test – applies the correct attribute", () => {
|
|
280
263
|
const dataTest = "test-button";
|
|
281
264
|
|
|
282
265
|
const component = mount(UButton, {
|
|
@@ -289,10 +272,8 @@ describe("UButton.vue", () => {
|
|
|
289
272
|
});
|
|
290
273
|
});
|
|
291
274
|
|
|
292
|
-
// Slots tests
|
|
293
275
|
describe("Slots", () => {
|
|
294
|
-
|
|
295
|
-
it("renders content from default slot", () => {
|
|
276
|
+
it("Default – renders content", () => {
|
|
296
277
|
const slotContent = "Custom Content";
|
|
297
278
|
const label = "Button";
|
|
298
279
|
|
|
@@ -309,8 +290,7 @@ describe("UButton.vue", () => {
|
|
|
309
290
|
expect(component.text()).toContain(slotContent);
|
|
310
291
|
});
|
|
311
292
|
|
|
312
|
-
|
|
313
|
-
it("renders content from left slot", () => {
|
|
293
|
+
it("Left – renders content", () => {
|
|
314
294
|
const label = "Button";
|
|
315
295
|
const slotText = "Left";
|
|
316
296
|
const slotClass = "left-content";
|
|
@@ -329,8 +309,7 @@ describe("UButton.vue", () => {
|
|
|
329
309
|
expect(component.find(`.${slotClass}`).text()).toBe(slotText);
|
|
330
310
|
});
|
|
331
311
|
|
|
332
|
-
|
|
333
|
-
it("renders content from right slot", () => {
|
|
312
|
+
it("Right – renders content", () => {
|
|
334
313
|
const label = "Button";
|
|
335
314
|
const slotText = "Right";
|
|
336
315
|
const slotClass = "right-content";
|
|
@@ -350,18 +329,15 @@ describe("UButton.vue", () => {
|
|
|
350
329
|
});
|
|
351
330
|
});
|
|
352
331
|
|
|
353
|
-
// Events tests
|
|
354
332
|
describe("Events", () => {
|
|
355
|
-
|
|
356
|
-
it("emits click event when clicked", async () => {
|
|
333
|
+
it("Click – emits when clicked", async () => {
|
|
357
334
|
const component = mount(UButton, {});
|
|
358
335
|
|
|
359
336
|
await component.trigger("click");
|
|
360
337
|
expect(component.emitted("click")).toBeTruthy();
|
|
361
338
|
});
|
|
362
339
|
|
|
363
|
-
|
|
364
|
-
it("does not emit click event when disabled", async () => {
|
|
340
|
+
it("Click – does not emit when disabled", async () => {
|
|
365
341
|
const disabled = true;
|
|
366
342
|
|
|
367
343
|
const component = mount(UButton, {
|
|
@@ -375,10 +351,8 @@ describe("UButton.vue", () => {
|
|
|
375
351
|
});
|
|
376
352
|
});
|
|
377
353
|
|
|
378
|
-
// Exposed refs tests
|
|
379
354
|
describe("Exposed refs", () => {
|
|
380
|
-
|
|
381
|
-
it("exposes buttonRef", () => {
|
|
355
|
+
it("Button – exposes ref", () => {
|
|
382
356
|
const component = mount(UButton, {});
|
|
383
357
|
|
|
384
358
|
expect(component.vm.buttonRef).toBeDefined();
|
|
@@ -6,7 +6,6 @@ import ULink from "../ULink.vue";
|
|
|
6
6
|
|
|
7
7
|
import type { Props } from "../types.ts";
|
|
8
8
|
|
|
9
|
-
// Create a mock router for testing router-link functionality
|
|
10
9
|
const router = createRouter({
|
|
11
10
|
history: createWebHistory(),
|
|
12
11
|
routes: [
|
|
@@ -16,10 +15,8 @@ const router = createRouter({
|
|
|
16
15
|
});
|
|
17
16
|
|
|
18
17
|
describe("ULink.vue", () => {
|
|
19
|
-
// Props tests
|
|
20
18
|
describe("Props", () => {
|
|
21
|
-
|
|
22
|
-
it("applies the correct size class", async () => {
|
|
19
|
+
it("Size – applies the correct size class", async () => {
|
|
23
20
|
const size = {
|
|
24
21
|
sm: "text-small",
|
|
25
22
|
md: "text-medium",
|
|
@@ -37,8 +34,7 @@ describe("ULink.vue", () => {
|
|
|
37
34
|
});
|
|
38
35
|
});
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
it("applies the correct color class", async () => {
|
|
37
|
+
it("Color – applies the correct color class", async () => {
|
|
42
38
|
const colors = [
|
|
43
39
|
"primary",
|
|
44
40
|
"secondary",
|
|
@@ -63,8 +59,7 @@ describe("ULink.vue", () => {
|
|
|
63
59
|
});
|
|
64
60
|
});
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
it("renders the correct label text", () => {
|
|
62
|
+
it("Label – renders the correct label text", () => {
|
|
68
63
|
const label = "Link Text";
|
|
69
64
|
|
|
70
65
|
const component = mount(ULink, {
|
|
@@ -76,8 +71,7 @@ describe("ULink.vue", () => {
|
|
|
76
71
|
expect(component.text()).toBe(label);
|
|
77
72
|
});
|
|
78
73
|
|
|
79
|
-
|
|
80
|
-
it("renders the correct href attribute", () => {
|
|
74
|
+
it("Href – renders the correct href attribute", () => {
|
|
81
75
|
const href = "https://example.com";
|
|
82
76
|
|
|
83
77
|
const component = mount(ULink, {
|
|
@@ -89,8 +83,7 @@ describe("ULink.vue", () => {
|
|
|
89
83
|
expect(component.attributes("href")).toBe(href);
|
|
90
84
|
});
|
|
91
85
|
|
|
92
|
-
|
|
93
|
-
it("applies the correct href prefix based on type", () => {
|
|
86
|
+
it("Type – applies the correct href prefix based on type", () => {
|
|
94
87
|
const types = {
|
|
95
88
|
phone: { href: "1234567890", expected: "tel:1234567890" },
|
|
96
89
|
email: { href: "test@example.com", expected: "mailto:test@example.com" },
|
|
@@ -109,8 +102,7 @@ describe("ULink.vue", () => {
|
|
|
109
102
|
});
|
|
110
103
|
});
|
|
111
104
|
|
|
112
|
-
|
|
113
|
-
it("renders as router-link when to prop is provided", async () => {
|
|
105
|
+
it("To – renders as router-link when to prop is provided", async () => {
|
|
114
106
|
const to = "/about";
|
|
115
107
|
|
|
116
108
|
const component = mount(ULink, {
|
|
@@ -126,8 +118,7 @@ describe("ULink.vue", () => {
|
|
|
126
118
|
expect(component.findComponent({ name: "RouterLink" }).exists()).toBe(true);
|
|
127
119
|
});
|
|
128
120
|
|
|
129
|
-
|
|
130
|
-
it("applies the correct target attribute", () => {
|
|
121
|
+
it("Target – applies the correct target attribute", () => {
|
|
131
122
|
const targets = ["_blank", "_self", "_parent", "_top"];
|
|
132
123
|
|
|
133
124
|
targets.forEach((target) => {
|
|
@@ -142,8 +133,7 @@ describe("ULink.vue", () => {
|
|
|
142
133
|
});
|
|
143
134
|
});
|
|
144
135
|
|
|
145
|
-
|
|
146
|
-
it("applies the correct rel attribute", () => {
|
|
136
|
+
it("Rel – applies the correct rel attribute", () => {
|
|
147
137
|
const rel = "noopener noreferrer";
|
|
148
138
|
|
|
149
139
|
const component = mount(ULink, {
|
|
@@ -156,8 +146,7 @@ describe("ULink.vue", () => {
|
|
|
156
146
|
expect(component.attributes("rel")).toBe(rel);
|
|
157
147
|
});
|
|
158
148
|
|
|
159
|
-
|
|
160
|
-
it("applies underlined class when underlined prop is true", () => {
|
|
149
|
+
it("Underlined – applies underlined class when underlined prop is true", () => {
|
|
161
150
|
const underlined = {
|
|
162
151
|
true: "underline",
|
|
163
152
|
false: "no-underline",
|
|
@@ -175,8 +164,7 @@ describe("ULink.vue", () => {
|
|
|
175
164
|
});
|
|
176
165
|
});
|
|
177
166
|
|
|
178
|
-
|
|
179
|
-
it("applies dashed class when dashed prop is true", () => {
|
|
167
|
+
it("Dashed – applies dashed class when dashed prop is true", () => {
|
|
180
168
|
const dashed = true;
|
|
181
169
|
const dashedClass = "decoration-dashed";
|
|
182
170
|
|
|
@@ -189,8 +177,7 @@ describe("ULink.vue", () => {
|
|
|
189
177
|
expect(component.attributes("class")).toContain(dashedClass);
|
|
190
178
|
});
|
|
191
179
|
|
|
192
|
-
|
|
193
|
-
it("applies dotted class when dotted prop is true", () => {
|
|
180
|
+
it("Dotted – applies dotted class when dotted prop is true", () => {
|
|
194
181
|
const dotted = true;
|
|
195
182
|
const dottedClass = "decoration-dotted";
|
|
196
183
|
|
|
@@ -203,8 +190,7 @@ describe("ULink.vue", () => {
|
|
|
203
190
|
expect(component.attributes("class")).toContain(dottedClass);
|
|
204
191
|
});
|
|
205
192
|
|
|
206
|
-
|
|
207
|
-
it("applies disabled class when disabled prop is true", () => {
|
|
193
|
+
it("Disabled – applies disabled class when disabled prop is true", () => {
|
|
208
194
|
const disabled = true;
|
|
209
195
|
|
|
210
196
|
const component = mount(ULink, {
|
|
@@ -216,8 +202,7 @@ describe("ULink.vue", () => {
|
|
|
216
202
|
expect(component.attributes("class")).toContain("cursor-not-allowed");
|
|
217
203
|
});
|
|
218
204
|
|
|
219
|
-
|
|
220
|
-
it("applies block class when block prop is true", () => {
|
|
205
|
+
it("Block – applies block class when block prop is true", () => {
|
|
221
206
|
const block = true;
|
|
222
207
|
const blockClass = "w-full";
|
|
223
208
|
|
|
@@ -230,8 +215,7 @@ describe("ULink.vue", () => {
|
|
|
230
215
|
expect(component.attributes("class")).toContain(blockClass);
|
|
231
216
|
});
|
|
232
217
|
|
|
233
|
-
|
|
234
|
-
it("applies the correct data-test attribute", () => {
|
|
218
|
+
it("Data Test – applies the correct data-test attribute", () => {
|
|
235
219
|
const dataTest = "test-link";
|
|
236
220
|
|
|
237
221
|
const component = mount(ULink, {
|
|
@@ -244,10 +228,8 @@ describe("ULink.vue", () => {
|
|
|
244
228
|
});
|
|
245
229
|
});
|
|
246
230
|
|
|
247
|
-
// Slots tests
|
|
248
231
|
describe("Slots", () => {
|
|
249
|
-
|
|
250
|
-
it("renders content from default slot", () => {
|
|
232
|
+
it("Default – renders content from default slot", () => {
|
|
251
233
|
const slotContent = "Custom Content";
|
|
252
234
|
const label = "Link";
|
|
253
235
|
|
|
@@ -264,8 +246,7 @@ describe("ULink.vue", () => {
|
|
|
264
246
|
expect(component.text()).toContain(slotContent);
|
|
265
247
|
});
|
|
266
248
|
|
|
267
|
-
|
|
268
|
-
it("renders content from default slot with router-link", () => {
|
|
249
|
+
it("Default – renders content from default slot with router-link", () => {
|
|
269
250
|
const slotContent = "Custom Content";
|
|
270
251
|
const label = "Link";
|
|
271
252
|
|
|
@@ -286,8 +267,7 @@ describe("ULink.vue", () => {
|
|
|
286
267
|
expect(component.text()).toContain(slotContent);
|
|
287
268
|
});
|
|
288
269
|
|
|
289
|
-
|
|
290
|
-
it("provides isActive and isExactActive bindings to default slot with router-link", () => {
|
|
270
|
+
it("Default – provides isActive and isExactActive bindings to default slot with router-link", () => {
|
|
291
271
|
const component = mount(ULink, {
|
|
292
272
|
props: {
|
|
293
273
|
to: "/about",
|
|
@@ -310,42 +290,36 @@ describe("ULink.vue", () => {
|
|
|
310
290
|
});
|
|
311
291
|
});
|
|
312
292
|
|
|
313
|
-
// Events tests
|
|
314
293
|
describe("Events", () => {
|
|
315
|
-
|
|
316
|
-
it("emits click event when clicked", async () => {
|
|
294
|
+
it("Click – emits click event when clicked", async () => {
|
|
317
295
|
const component = mount(ULink, {});
|
|
318
296
|
|
|
319
297
|
await component.trigger("click");
|
|
320
298
|
expect(component.emitted("click")).toBeTruthy();
|
|
321
299
|
});
|
|
322
300
|
|
|
323
|
-
|
|
324
|
-
it("emits mouseover event when hovered", async () => {
|
|
301
|
+
it("Mouseover – emits mouseover event when hovered", async () => {
|
|
325
302
|
const component = mount(ULink, {});
|
|
326
303
|
|
|
327
304
|
await component.trigger("mouseover");
|
|
328
305
|
expect(component.emitted("mouseover")).toBeTruthy();
|
|
329
306
|
});
|
|
330
307
|
|
|
331
|
-
|
|
332
|
-
it("emits focus event when focused", async () => {
|
|
308
|
+
it("Focus – emits focus event when focused", async () => {
|
|
333
309
|
const component = mount(ULink, {});
|
|
334
310
|
|
|
335
311
|
await component.trigger("focus");
|
|
336
312
|
expect(component.emitted("focus")).toBeTruthy();
|
|
337
313
|
});
|
|
338
314
|
|
|
339
|
-
|
|
340
|
-
it("emits blur event when blurred", async () => {
|
|
315
|
+
it("Blur – emits blur event when blurred", async () => {
|
|
341
316
|
const component = mount(ULink, {});
|
|
342
317
|
|
|
343
318
|
await component.trigger("blur");
|
|
344
319
|
expect(component.emitted("blur")).toBeTruthy();
|
|
345
320
|
});
|
|
346
321
|
|
|
347
|
-
|
|
348
|
-
it("emits keydown event when key is pressed", async () => {
|
|
322
|
+
it("Keydown – emits keydown event when key is pressed", async () => {
|
|
349
323
|
const component = mount(ULink, {});
|
|
350
324
|
|
|
351
325
|
await component.trigger("keydown");
|
|
@@ -353,10 +327,8 @@ describe("ULink.vue", () => {
|
|
|
353
327
|
});
|
|
354
328
|
});
|
|
355
329
|
|
|
356
|
-
// Exposed refs tests
|
|
357
330
|
describe("Exposed refs", () => {
|
|
358
|
-
|
|
359
|
-
it("exposes linkRef", () => {
|
|
331
|
+
it("Link – exposes linkRef", () => {
|
|
360
332
|
const component = mount(ULink, {});
|
|
361
333
|
|
|
362
334
|
expect(component.vm.linkRef).toBeDefined();
|
|
@@ -19,10 +19,8 @@ describe("UToggle.vue", () => {
|
|
|
19
19
|
];
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
// Props tests
|
|
23
22
|
describe("Props", () => {
|
|
24
|
-
|
|
25
|
-
it("applies the correct size class", async () => {
|
|
23
|
+
it("Size – applies the correct size class", async () => {
|
|
26
24
|
const size = {
|
|
27
25
|
"2xs": "text-small",
|
|
28
26
|
xs: "text-small",
|
|
@@ -47,8 +45,7 @@ describe("UToggle.vue", () => {
|
|
|
47
45
|
});
|
|
48
46
|
});
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
it("renders the correct number of options", () => {
|
|
48
|
+
it("Options – renders the correct number of options", () => {
|
|
52
49
|
const component = mount(UToggle, {
|
|
53
50
|
props: {
|
|
54
51
|
options,
|
|
@@ -61,8 +58,47 @@ describe("UToggle.vue", () => {
|
|
|
61
58
|
expect(buttons.length).toBe(options.length);
|
|
62
59
|
});
|
|
63
60
|
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
it("Options – disables individual option when option disabled prop is true", () => {
|
|
62
|
+
const customOptions: UToggleOption[] = [
|
|
63
|
+
{ value: "option1", label: "Option 1" },
|
|
64
|
+
{ value: "option2", label: "Option 2", disabled: true },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const component = mount(UToggle, {
|
|
68
|
+
props: {
|
|
69
|
+
options: customOptions,
|
|
70
|
+
name,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const buttons = component.findAllComponents(UButton);
|
|
75
|
+
|
|
76
|
+
expect(buttons[0].attributes("disabled")).toBeUndefined();
|
|
77
|
+
expect(buttons[1].attributes("disabled")).toBeDefined();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("Options – set icon for individual options", () => {
|
|
81
|
+
const iconOptions: UToggleOption[] = [
|
|
82
|
+
{ value: "option1", label: "Option 1", icon: "star" },
|
|
83
|
+
{ value: "option2", label: "Option 2", leftIcon: "check" },
|
|
84
|
+
{ value: "option3", label: "Option 3", rightIcon: "close" },
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
const component = mount(UToggle, {
|
|
88
|
+
props: {
|
|
89
|
+
options: iconOptions,
|
|
90
|
+
name,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const buttons = component.findAllComponents(UButton);
|
|
95
|
+
|
|
96
|
+
expect(buttons[0].props("icon")).toBe("star");
|
|
97
|
+
expect(buttons[1].props("leftIcon")).toBe("check");
|
|
98
|
+
expect(buttons[2].props("rightIcon")).toBe("close");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("Model Value – correctly selects option based on modelValue for single selection", async () => {
|
|
66
102
|
const selectedClass = "bg-primary";
|
|
67
103
|
const selectedValue = "option2";
|
|
68
104
|
|
|
@@ -79,8 +115,7 @@ describe("UToggle.vue", () => {
|
|
|
79
115
|
expect(buttons[1].attributes("class")).toContain(selectedClass);
|
|
80
116
|
});
|
|
81
117
|
|
|
82
|
-
|
|
83
|
-
it("correctly selects options based on modelValue for multiple selection", async () => {
|
|
118
|
+
it("Model Value – correctly selects options based on modelValue for multiple selection", async () => {
|
|
84
119
|
const selectedClass = "bg-primary";
|
|
85
120
|
const selectedValues = ["option1", "option3"];
|
|
86
121
|
|
|
@@ -99,8 +134,7 @@ describe("UToggle.vue", () => {
|
|
|
99
134
|
expect(multiButtons[2].attributes("class")).toContain(selectedClass);
|
|
100
135
|
});
|
|
101
136
|
|
|
102
|
-
|
|
103
|
-
it("allows multiple selections when multiple prop is true", async () => {
|
|
137
|
+
it("Multiple – allows multiple selections when multiple prop is true", async () => {
|
|
104
138
|
const component = mount(UToggle, {
|
|
105
139
|
props: {
|
|
106
140
|
options,
|
|
@@ -118,8 +152,7 @@ describe("UToggle.vue", () => {
|
|
|
118
152
|
expect(emittedValue).toEqual(["option1", "option2"]);
|
|
119
153
|
});
|
|
120
154
|
|
|
121
|
-
|
|
122
|
-
it("applies split class when split prop is true", () => {
|
|
155
|
+
it("Split – applies split class when split prop is true", () => {
|
|
123
156
|
const split = true;
|
|
124
157
|
const splitClasses = "flex-wrap";
|
|
125
158
|
|
|
@@ -133,8 +166,7 @@ describe("UToggle.vue", () => {
|
|
|
133
166
|
expect(component.attributes("class")).toContain(splitClasses);
|
|
134
167
|
});
|
|
135
168
|
|
|
136
|
-
|
|
137
|
-
it("applies split class when split prop is true", () => {
|
|
169
|
+
it("Split – applies unsplit class when split prop is false", () => {
|
|
138
170
|
const split = false;
|
|
139
171
|
const unsplitClasses = "gap-px";
|
|
140
172
|
|
|
@@ -148,8 +180,7 @@ describe("UToggle.vue", () => {
|
|
|
148
180
|
expect(component.attributes("class")).toContain(unsplitClasses);
|
|
149
181
|
});
|
|
150
182
|
|
|
151
|
-
|
|
152
|
-
it("disables all options when disabled prop is true", () => {
|
|
183
|
+
it("Disabled – disables all options when disabled prop is true", () => {
|
|
153
184
|
const disabled = true;
|
|
154
185
|
|
|
155
186
|
const component = mount(UToggle, {
|
|
@@ -167,28 +198,7 @@ describe("UToggle.vue", () => {
|
|
|
167
198
|
});
|
|
168
199
|
});
|
|
169
200
|
|
|
170
|
-
|
|
171
|
-
it("disables individual option when option disabled prop is true", () => {
|
|
172
|
-
const customOptions: UToggleOption[] = [
|
|
173
|
-
{ value: "option1", label: "Option 1" },
|
|
174
|
-
{ value: "option2", label: "Option 2", disabled: true },
|
|
175
|
-
];
|
|
176
|
-
|
|
177
|
-
const component = mount(UToggle, {
|
|
178
|
-
props: {
|
|
179
|
-
options: customOptions,
|
|
180
|
-
name,
|
|
181
|
-
},
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
const buttons = component.findAllComponents(UButton);
|
|
185
|
-
|
|
186
|
-
expect(buttons[0].attributes("disabled")).toBeUndefined();
|
|
187
|
-
expect(buttons[1].attributes("disabled")).toBeDefined();
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
// Block prop
|
|
191
|
-
it("applies block class when block prop is true", () => {
|
|
201
|
+
it("Block – applies block class when block prop is true", () => {
|
|
192
202
|
const block = true;
|
|
193
203
|
const blockClasses = "w-full";
|
|
194
204
|
|
|
@@ -203,8 +213,7 @@ describe("UToggle.vue", () => {
|
|
|
203
213
|
expect(component.attributes("class")).toContain(blockClasses);
|
|
204
214
|
});
|
|
205
215
|
|
|
206
|
-
|
|
207
|
-
it("applies round class to buttons when round prop is true", () => {
|
|
216
|
+
it("Round – applies round class to buttons when round prop is true", () => {
|
|
208
217
|
const round = true;
|
|
209
218
|
const roundClasses = "rounded-full";
|
|
210
219
|
|
|
@@ -221,8 +230,7 @@ describe("UToggle.vue", () => {
|
|
|
221
230
|
expect(button.attributes("class")).toContain(roundClasses);
|
|
222
231
|
});
|
|
223
232
|
|
|
224
|
-
|
|
225
|
-
it("applies square class to buttons when square prop is true", () => {
|
|
233
|
+
it("Square – applies square class to buttons when square prop is true", () => {
|
|
226
234
|
const square = true;
|
|
227
235
|
|
|
228
236
|
const component = mount(UToggle, {
|
|
@@ -239,8 +247,7 @@ describe("UToggle.vue", () => {
|
|
|
239
247
|
expect(button.attributes("class")).toContain("p-");
|
|
240
248
|
});
|
|
241
249
|
|
|
242
|
-
|
|
243
|
-
it("applies the correct id attribute", () => {
|
|
250
|
+
it("Id – applies the correct id attribute", () => {
|
|
244
251
|
const id = "test-toggle-id";
|
|
245
252
|
|
|
246
253
|
const component = mount(UToggle, {
|
|
@@ -253,8 +260,7 @@ describe("UToggle.vue", () => {
|
|
|
253
260
|
expect(component.attributes("id")).toBe(id);
|
|
254
261
|
});
|
|
255
262
|
|
|
256
|
-
|
|
257
|
-
it("applies the correct data-test attribute", () => {
|
|
263
|
+
it("Data Test – applies the correct data-test attribute", () => {
|
|
258
264
|
const dataTest = "test-toggle";
|
|
259
265
|
|
|
260
266
|
const component = mount(UToggle, {
|
|
@@ -266,34 +272,10 @@ describe("UToggle.vue", () => {
|
|
|
266
272
|
|
|
267
273
|
expect(component.attributes("data-test")).toBe(dataTest);
|
|
268
274
|
});
|
|
269
|
-
|
|
270
|
-
// Icon, leftIcon, rightIcon props
|
|
271
|
-
it("passes icon props to UButton components", () => {
|
|
272
|
-
const iconOptions: UToggleOption[] = [
|
|
273
|
-
{ value: "option1", label: "Option 1", icon: "star" },
|
|
274
|
-
{ value: "option2", label: "Option 2", leftIcon: "check" },
|
|
275
|
-
{ value: "option3", label: "Option 3", rightIcon: "close" },
|
|
276
|
-
];
|
|
277
|
-
|
|
278
|
-
const component = mount(UToggle, {
|
|
279
|
-
props: {
|
|
280
|
-
options: iconOptions,
|
|
281
|
-
name,
|
|
282
|
-
},
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
const buttons = component.findAllComponents(UButton);
|
|
286
|
-
|
|
287
|
-
expect(buttons[0].props("icon")).toBe("star");
|
|
288
|
-
expect(buttons[1].props("leftIcon")).toBe("check");
|
|
289
|
-
expect(buttons[2].props("rightIcon")).toBe("close");
|
|
290
|
-
});
|
|
291
275
|
});
|
|
292
276
|
|
|
293
|
-
// Slots tests
|
|
294
277
|
describe("Slots", () => {
|
|
295
|
-
|
|
296
|
-
it("renders content from left slot", () => {
|
|
278
|
+
it("Left – renders content from left slot", () => {
|
|
297
279
|
const slotText = "Left";
|
|
298
280
|
const slotClass = "left-content";
|
|
299
281
|
|
|
@@ -310,8 +292,7 @@ describe("UToggle.vue", () => {
|
|
|
310
292
|
expect(component.find(`.${slotClass}`).text()).toBe(slotText);
|
|
311
293
|
});
|
|
312
294
|
|
|
313
|
-
|
|
314
|
-
it("renders content from option slot", () => {
|
|
295
|
+
it("Option – renders content from option slot", () => {
|
|
315
296
|
const slotText = "Custom Option";
|
|
316
297
|
const slotClass = "option-content";
|
|
317
298
|
|
|
@@ -328,26 +309,7 @@ describe("UToggle.vue", () => {
|
|
|
328
309
|
expect(component.find(`.${slotClass}`).text()).toBe(slotText);
|
|
329
310
|
});
|
|
330
311
|
|
|
331
|
-
|
|
332
|
-
it("renders content from right slot", () => {
|
|
333
|
-
const slotText = "Right";
|
|
334
|
-
const slotClass = "right-content";
|
|
335
|
-
|
|
336
|
-
const component = mount(UToggle, {
|
|
337
|
-
props: {
|
|
338
|
-
options,
|
|
339
|
-
name,
|
|
340
|
-
},
|
|
341
|
-
slots: {
|
|
342
|
-
right: `<span class='${slotClass}'>${slotText}</span>`,
|
|
343
|
-
},
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
expect(component.find(`.${slotClass}`).text()).toBe(slotText);
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
// Slot bindings
|
|
350
|
-
it("provides correct bindings to slots", () => {
|
|
312
|
+
it("Option – provides correct bindings to slots", () => {
|
|
351
313
|
const optionIndex = "0";
|
|
352
314
|
const bindingOptions: UToggleOption[] = [
|
|
353
315
|
{ value: "option1", label: "Option 1", icon: "star" },
|
|
@@ -380,12 +342,27 @@ describe("UToggle.vue", () => {
|
|
|
380
342
|
expect(component.find(`.${iconClass}`).text()).toBe(bindingOptions[0].icon);
|
|
381
343
|
expect(component.find(`.${indexClass}`).text()).toBe(optionIndex);
|
|
382
344
|
});
|
|
345
|
+
|
|
346
|
+
it("Right – renders content from right slot", () => {
|
|
347
|
+
const slotText = "Right";
|
|
348
|
+
const slotClass = "right-content";
|
|
349
|
+
|
|
350
|
+
const component = mount(UToggle, {
|
|
351
|
+
props: {
|
|
352
|
+
options,
|
|
353
|
+
name,
|
|
354
|
+
},
|
|
355
|
+
slots: {
|
|
356
|
+
right: `<span class='${slotClass}'>${slotText}</span>`,
|
|
357
|
+
},
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
expect(component.find(`.${slotClass}`).text()).toBe(slotText);
|
|
361
|
+
});
|
|
383
362
|
});
|
|
384
363
|
|
|
385
|
-
// Events tests
|
|
386
364
|
describe("Events", () => {
|
|
387
|
-
|
|
388
|
-
it("emits update:modelValue event when option is clicked", async () => {
|
|
365
|
+
it("Model Value – emits update:modelValue event when option is clicked", async () => {
|
|
389
366
|
const component = mount(UToggle, {
|
|
390
367
|
props: {
|
|
391
368
|
options,
|
|
@@ -400,8 +377,7 @@ describe("UToggle.vue", () => {
|
|
|
400
377
|
expect(emittedValue).toBe(options[0].value);
|
|
401
378
|
});
|
|
402
379
|
|
|
403
|
-
|
|
404
|
-
it("calls option onClick callback when option is clicked", async () => {
|
|
380
|
+
it("Option Click – calls option onClick callback when option is clicked", async () => {
|
|
405
381
|
const onClick = vi.fn();
|
|
406
382
|
const callbackOptions: UToggleOption[] = [{ value: "option1", label: "Option 1", onClick }];
|
|
407
383
|
|
|
@@ -421,10 +397,8 @@ describe("UToggle.vue", () => {
|
|
|
421
397
|
});
|
|
422
398
|
});
|
|
423
399
|
|
|
424
|
-
// Exposed refs tests
|
|
425
400
|
describe("Exposed refs", () => {
|
|
426
|
-
|
|
427
|
-
it("exposes optionsRef", () => {
|
|
401
|
+
it("Options – exposes optionsRef", () => {
|
|
428
402
|
const component = mount(UToggle, {
|
|
429
403
|
props: {
|
|
430
404
|
name,
|
|
@@ -7,20 +7,16 @@ import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
|
7
7
|
import type { Props } from "../types.ts";
|
|
8
8
|
|
|
9
9
|
describe("UDivider", () => {
|
|
10
|
-
// Props
|
|
11
10
|
describe("Props", () => {
|
|
12
|
-
|
|
13
|
-
it("shows only one divider when no label, icon, or slot content is provided", () => {
|
|
11
|
+
it("No props – shows only one divider when no label, icon, or slot content is provided", () => {
|
|
14
12
|
const component = mount(UDivider);
|
|
15
13
|
|
|
16
|
-
// Should have only one divider element
|
|
17
14
|
const dividers = component.findAll("[vl-key='divider']");
|
|
18
15
|
|
|
19
16
|
expect(dividers.length).toBe(1);
|
|
20
17
|
});
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
it("renders with label prop", () => {
|
|
19
|
+
it("Label – renders with label prop", () => {
|
|
24
20
|
const label = "Divider Label";
|
|
25
21
|
|
|
26
22
|
const component = mount(UDivider, {
|
|
@@ -29,50 +25,45 @@ describe("UDivider", () => {
|
|
|
29
25
|
},
|
|
30
26
|
});
|
|
31
27
|
|
|
32
|
-
// Should have two divider elements (before and after icon)
|
|
33
28
|
const dividers = component.findAll("[vl-key='divider']");
|
|
34
29
|
|
|
35
30
|
expect(dividers.length).toBe(2);
|
|
36
31
|
expect(component.text()).toContain(label);
|
|
37
32
|
});
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
it("Label – prioritizes label over icon when both are provided", () => {
|
|
35
|
+
const label = "Test Label";
|
|
41
36
|
const icon = "star";
|
|
42
37
|
|
|
43
38
|
const component = mount(UDivider, {
|
|
44
39
|
props: {
|
|
40
|
+
label,
|
|
45
41
|
icon,
|
|
46
42
|
},
|
|
47
43
|
});
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const iconComponent = component.findComponent(UIcon);
|
|
52
|
-
|
|
53
|
-
expect(dividers.length).toBe(2);
|
|
54
|
-
expect(iconComponent.exists()).toBe(true);
|
|
55
|
-
expect(iconComponent.props("name")).toBe(icon);
|
|
45
|
+
expect(component.text()).toContain(label);
|
|
46
|
+
expect(component.findComponent(UIcon).exists()).toBe(false);
|
|
56
47
|
});
|
|
57
48
|
|
|
58
|
-
|
|
59
|
-
it("prioritizes label over icon when both are provided", () => {
|
|
60
|
-
const label = "Test Label";
|
|
49
|
+
it("Icon – renders with icon prop", () => {
|
|
61
50
|
const icon = "star";
|
|
62
51
|
|
|
63
52
|
const component = mount(UDivider, {
|
|
64
53
|
props: {
|
|
65
|
-
label,
|
|
66
54
|
icon,
|
|
67
55
|
},
|
|
68
56
|
});
|
|
69
57
|
|
|
70
|
-
|
|
71
|
-
|
|
58
|
+
const dividers = component.findAll("[vl-key='divider']");
|
|
59
|
+
const iconComponent = component.findComponent(UIcon);
|
|
60
|
+
|
|
61
|
+
expect(dividers.length).toBe(2);
|
|
62
|
+
expect(iconComponent.exists()).toBe(true);
|
|
63
|
+
expect(iconComponent.props("name")).toBe(icon);
|
|
72
64
|
});
|
|
73
65
|
|
|
74
|
-
|
|
75
|
-
it("applies correct size classes", () => {
|
|
66
|
+
it("Size – applies correct size classes", () => {
|
|
76
67
|
const sizeClasses = {
|
|
77
68
|
xs: "border-t",
|
|
78
69
|
sm: "border-t-[2px]",
|
|
@@ -94,8 +85,7 @@ describe("UDivider", () => {
|
|
|
94
85
|
});
|
|
95
86
|
});
|
|
96
87
|
|
|
97
|
-
|
|
98
|
-
it("applies correct color classes", () => {
|
|
88
|
+
it("Color – applies correct color classes", () => {
|
|
99
89
|
const colorClasses = {
|
|
100
90
|
primary: "border-primary",
|
|
101
91
|
secondary: "border-secondary",
|
|
@@ -122,8 +112,7 @@ describe("UDivider", () => {
|
|
|
122
112
|
});
|
|
123
113
|
});
|
|
124
114
|
|
|
125
|
-
|
|
126
|
-
it("applies dashed class when dashed prop is true", () => {
|
|
115
|
+
it("Dashed – applies dashed class when dashed prop is true", () => {
|
|
127
116
|
const dashed = true;
|
|
128
117
|
const expectedClass = "border-dashed";
|
|
129
118
|
|
|
@@ -136,8 +125,7 @@ describe("UDivider", () => {
|
|
|
136
125
|
expect(component.find(`[vl-key='divider']`).classes()).toContain(expectedClass);
|
|
137
126
|
});
|
|
138
127
|
|
|
139
|
-
|
|
140
|
-
it("applies dotted class when dotted prop is true", () => {
|
|
128
|
+
it("Dotted – applies dotted class when dotted prop is true", () => {
|
|
141
129
|
const dotted = true;
|
|
142
130
|
const expectedClass = "border-dotted";
|
|
143
131
|
|
|
@@ -150,8 +138,7 @@ describe("UDivider", () => {
|
|
|
150
138
|
expect(component.find(`[vl-key='divider']`).classes()).toContain(expectedClass);
|
|
151
139
|
});
|
|
152
140
|
|
|
153
|
-
|
|
154
|
-
it("applies vertical classes when vertical prop is true", () => {
|
|
141
|
+
it("Vertical – applies vertical classes when vertical prop is true", () => {
|
|
155
142
|
const verticalVariants = {
|
|
156
143
|
true: {
|
|
157
144
|
wrapper: "flex-col",
|
|
@@ -170,16 +157,12 @@ describe("UDivider", () => {
|
|
|
170
157
|
},
|
|
171
158
|
});
|
|
172
159
|
|
|
173
|
-
// Check component has correct flex class
|
|
174
160
|
expect(component.classes()).toContain(classes.wrapper);
|
|
175
|
-
|
|
176
|
-
// Check divider has correct border class
|
|
177
161
|
expect(component.find("[vl-key='divider']").classes()).toContain(classes.divider);
|
|
178
162
|
});
|
|
179
163
|
});
|
|
180
164
|
|
|
181
|
-
|
|
182
|
-
it("applies data-test attribute", () => {
|
|
165
|
+
it("Data Test – applies data-test attribute", () => {
|
|
183
166
|
const dataTest = "divider-test";
|
|
184
167
|
|
|
185
168
|
const component = mount(UDivider, {
|
|
@@ -192,10 +175,8 @@ describe("UDivider", () => {
|
|
|
192
175
|
});
|
|
193
176
|
});
|
|
194
177
|
|
|
195
|
-
// Slots
|
|
196
178
|
describe("Slots", () => {
|
|
197
|
-
|
|
198
|
-
it("renders content in default slot", () => {
|
|
179
|
+
it("Default – renders content in default slot", () => {
|
|
199
180
|
const slotClass = "custom-content";
|
|
200
181
|
const slotContent = "Custom Content";
|
|
201
182
|
|
|
@@ -205,7 +186,6 @@ describe("UDivider", () => {
|
|
|
205
186
|
},
|
|
206
187
|
});
|
|
207
188
|
|
|
208
|
-
// Should have two divider elements (before and after slot content)
|
|
209
189
|
const dividers = component.findAll("[vl-key='divider']");
|
|
210
190
|
|
|
211
191
|
expect(dividers.length).toBe(2);
|
|
@@ -213,7 +193,7 @@ describe("UDivider", () => {
|
|
|
213
193
|
expect(component.text()).toContain(slotContent);
|
|
214
194
|
});
|
|
215
195
|
|
|
216
|
-
it("provides label and icon-name bindings to default slot", () => {
|
|
196
|
+
it("Default – provides label and icon-name bindings to default slot", () => {
|
|
217
197
|
const slotClass = "custom-content";
|
|
218
198
|
const label = "Test Label";
|
|
219
199
|
const icon = "star";
|
|
@@ -237,10 +217,8 @@ describe("UDivider", () => {
|
|
|
237
217
|
});
|
|
238
218
|
});
|
|
239
219
|
|
|
240
|
-
// Exposed refs
|
|
241
220
|
describe("Exposed refs", () => {
|
|
242
|
-
|
|
243
|
-
it("exposes wrapperRef", () => {
|
|
221
|
+
it("Wrapper – exposes wrapperRef", () => {
|
|
244
222
|
const component = mount(UDivider);
|
|
245
223
|
|
|
246
224
|
expect(component.vm.wrapperRef).toBeDefined();
|
|
@@ -139,22 +139,7 @@ watch(
|
|
|
139
139
|
const marginTop = parseFloat(styles.marginTop || "0");
|
|
140
140
|
const marginBottom = parseFloat(styles.marginBottom || "0");
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
const childStyles = childDiv && window.getComputedStyle(childDiv);
|
|
144
|
-
const childMarginTop = parseFloat(childStyles?.marginTop || "0");
|
|
145
|
-
const childMarginBottom = parseFloat(childStyles?.marginBottom || "0");
|
|
146
|
-
const childPaddingTop = parseFloat(childStyles?.paddingTop || "0");
|
|
147
|
-
const childPaddingBottom = parseFloat(childStyles?.paddingBottom || "0");
|
|
148
|
-
|
|
149
|
-
return (
|
|
150
|
-
elHeight +
|
|
151
|
-
marginTop +
|
|
152
|
-
marginBottom +
|
|
153
|
-
childMarginTop +
|
|
154
|
-
childMarginBottom +
|
|
155
|
-
childPaddingTop +
|
|
156
|
-
childPaddingBottom
|
|
157
|
-
);
|
|
142
|
+
return elHeight + marginTop + marginBottom;
|
|
158
143
|
})
|
|
159
144
|
.reduce((acc, cur) => acc + cur, 0);
|
|
160
145
|
|
|
@@ -167,27 +152,29 @@ watch(
|
|
|
167
152
|
|
|
168
153
|
const inputEl = listboxInputRef.value?.input as HTMLInputElement | undefined;
|
|
169
154
|
let listboxInputHeight = 0;
|
|
170
|
-
|
|
171
|
-
let
|
|
155
|
+
|
|
156
|
+
let listboxInputWrapperPaddingTop = 0;
|
|
172
157
|
|
|
173
158
|
if (inputEl) {
|
|
174
159
|
const listboxInputStyle = getComputedStyle(inputEl);
|
|
160
|
+
const listboxInputWrapperStyle = getComputedStyle(
|
|
161
|
+
inputEl.parentElement?.parentElement?.parentElement as Element,
|
|
162
|
+
);
|
|
175
163
|
|
|
176
164
|
listboxInputHeight = parseFloat(listboxInputStyle.height || "0");
|
|
177
|
-
|
|
178
|
-
|
|
165
|
+
|
|
166
|
+
listboxInputWrapperPaddingTop = parseFloat(listboxInputWrapperStyle.paddingTop || "0");
|
|
179
167
|
}
|
|
180
168
|
|
|
181
169
|
wrapperMaxHeight.value = `${
|
|
182
170
|
maxHeight +
|
|
183
|
-
wrapperGap +
|
|
171
|
+
(props.searchable ? wrapperGap : 0) +
|
|
184
172
|
wrapperPaddingTop +
|
|
185
173
|
wrapperPaddingBottom +
|
|
186
174
|
wrapperBorderTop +
|
|
187
175
|
wrapperBorderBottom +
|
|
188
176
|
listboxInputHeight +
|
|
189
|
-
|
|
190
|
-
listboxInputPaddingBottom
|
|
177
|
+
(props.searchable ? listboxInputWrapperPaddingTop : 0)
|
|
191
178
|
}px`;
|
|
192
179
|
});
|
|
193
180
|
},
|