vueless 1.3.6-beta.3 → 1.3.6-beta.5
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
|
@@ -98,7 +98,7 @@ Gap.parameters = {
|
|
|
98
98
|
|
|
99
99
|
export const RowGap = EnumTemplate.bind({});
|
|
100
100
|
RowGap.args = { enum: "rowGap" };
|
|
101
|
-
|
|
101
|
+
RowGap.parameters = {
|
|
102
102
|
docs: {
|
|
103
103
|
description: {
|
|
104
104
|
story: "Vertical gap override.",
|
|
@@ -108,7 +108,7 @@ Gap.parameters = {
|
|
|
108
108
|
|
|
109
109
|
export const ColGap = EnumTemplate.bind({});
|
|
110
110
|
ColGap.args = { enum: "colGap" };
|
|
111
|
-
|
|
111
|
+
ColGap.parameters = {
|
|
112
112
|
docs: {
|
|
113
113
|
description: {
|
|
114
114
|
story: "Horizontal gap override.",
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { mount } from "@vue/test-utils";
|
|
2
|
+
import { describe, it, expect } from "vitest";
|
|
3
|
+
|
|
4
|
+
import UGrid from "../UGrid.vue";
|
|
5
|
+
|
|
6
|
+
import type { Props } from "../types";
|
|
7
|
+
|
|
8
|
+
describe("UGrid.vue", () => {
|
|
9
|
+
describe("Props", () => {
|
|
10
|
+
it("Cols – applies the correct cols class", () => {
|
|
11
|
+
const colsClasses = {
|
|
12
|
+
"1": "grid-cols-1",
|
|
13
|
+
"2": "grid-cols-2",
|
|
14
|
+
"3": "grid-cols-3",
|
|
15
|
+
"4": "grid-cols-4",
|
|
16
|
+
"5": "grid-cols-5",
|
|
17
|
+
"6": "grid-cols-6",
|
|
18
|
+
"7": "grid-cols-7",
|
|
19
|
+
"8": "grid-cols-8",
|
|
20
|
+
"9": "grid-cols-9",
|
|
21
|
+
"10": "grid-cols-10",
|
|
22
|
+
"11": "grid-cols-11",
|
|
23
|
+
"12": "grid-cols-12",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
Object.entries(colsClasses).forEach(([cols, classes]) => {
|
|
27
|
+
const component = mount(UGrid, {
|
|
28
|
+
props: {
|
|
29
|
+
cols: cols as Props["cols"],
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
expect(component.attributes("class")).toContain(classes);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("Rows – applies the correct rows class", () => {
|
|
38
|
+
const rowsClasses = {
|
|
39
|
+
"1": "grid-rows-1",
|
|
40
|
+
"2": "grid-rows-2",
|
|
41
|
+
"3": "grid-rows-3",
|
|
42
|
+
"4": "grid-rows-4",
|
|
43
|
+
"5": "grid-rows-5",
|
|
44
|
+
"6": "grid-rows-6",
|
|
45
|
+
"7": "grid-rows-7",
|
|
46
|
+
"8": "grid-rows-8",
|
|
47
|
+
"9": "grid-rows-9",
|
|
48
|
+
"10": "grid-rows-10",
|
|
49
|
+
"11": "grid-rows-11",
|
|
50
|
+
"12": "grid-rows-12",
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Object.entries(rowsClasses).forEach(([rows, classes]) => {
|
|
54
|
+
const component = mount(UGrid, {
|
|
55
|
+
props: {
|
|
56
|
+
rows: rows as Props["rows"],
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
expect(component.attributes("class")).toContain(classes);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("Gap – applies the correct gap class", () => {
|
|
65
|
+
const gapClasses = {
|
|
66
|
+
none: "gap-0",
|
|
67
|
+
"2xs": "gap-1",
|
|
68
|
+
xs: "gap-2",
|
|
69
|
+
sm: "gap-3",
|
|
70
|
+
md: "gap-4",
|
|
71
|
+
lg: "gap-5",
|
|
72
|
+
xl: "gap-6",
|
|
73
|
+
"2xl": "gap-8",
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
Object.entries(gapClasses).forEach(([gap, classes]) => {
|
|
77
|
+
const component = mount(UGrid, {
|
|
78
|
+
props: {
|
|
79
|
+
gap: gap as Props["gap"],
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(component.attributes("class")).toContain(classes);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("Row Gap – applies the correct row gap class", () => {
|
|
88
|
+
const rowGapClasses = {
|
|
89
|
+
none: "gap-y-0",
|
|
90
|
+
"2xs": "gap-y-1",
|
|
91
|
+
xs: "gap-y-2",
|
|
92
|
+
sm: "gap-y-3",
|
|
93
|
+
md: "gap-y-4",
|
|
94
|
+
lg: "gap-y-5",
|
|
95
|
+
xl: "gap-y-6",
|
|
96
|
+
"2xl": "gap-y-8",
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
Object.entries(rowGapClasses).forEach(([rowGap, classes]) => {
|
|
100
|
+
const component = mount(UGrid, {
|
|
101
|
+
props: {
|
|
102
|
+
rowGap: rowGap as Props["rowGap"],
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
expect(component.attributes("class")).toContain(classes);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("Col Gap – applies the correct col gap class", () => {
|
|
111
|
+
const colGapClasses = {
|
|
112
|
+
none: "gap-x-0",
|
|
113
|
+
"2xs": "gap-x-1",
|
|
114
|
+
xs: "gap-x-2",
|
|
115
|
+
sm: "gap-x-3",
|
|
116
|
+
md: "gap-x-4",
|
|
117
|
+
lg: "gap-x-5",
|
|
118
|
+
xl: "gap-x-6",
|
|
119
|
+
"2xl": "gap-x-8",
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
Object.entries(colGapClasses).forEach(([colGap, classes]) => {
|
|
123
|
+
const component = mount(UGrid, {
|
|
124
|
+
props: {
|
|
125
|
+
colGap: colGap as Props["colGap"],
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
expect(component.attributes("class")).toContain(classes);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("Align – applies the correct align class", () => {
|
|
134
|
+
const alignClasses = {
|
|
135
|
+
start: "items-start",
|
|
136
|
+
end: "items-end",
|
|
137
|
+
center: "items-center",
|
|
138
|
+
stretch: "items-stretch",
|
|
139
|
+
baseline: "items-baseline",
|
|
140
|
+
normal: "items-normal",
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
Object.entries(alignClasses).forEach(([align, classes]) => {
|
|
144
|
+
const component = mount(UGrid, {
|
|
145
|
+
props: {
|
|
146
|
+
align: align as Props["align"],
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
expect(component.attributes("class")).toContain(classes);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("Content – applies the correct content class", () => {
|
|
155
|
+
const contentClasses = {
|
|
156
|
+
start: "content-start",
|
|
157
|
+
end: "content-end",
|
|
158
|
+
center: "content-center",
|
|
159
|
+
around: "content-around",
|
|
160
|
+
evenly: "content-evenly",
|
|
161
|
+
between: "content-between",
|
|
162
|
+
normal: "content-normal",
|
|
163
|
+
stretch: "content-stretch",
|
|
164
|
+
baseline: "content-baseline",
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
Object.entries(contentClasses).forEach(([content, classes]) => {
|
|
168
|
+
const component = mount(UGrid, {
|
|
169
|
+
props: {
|
|
170
|
+
content: content as Props["content"],
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
expect(component.attributes("class")).toContain(classes);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it("Justify – applies the correct justify class", () => {
|
|
179
|
+
const justifyClasses = {
|
|
180
|
+
start: "justify-items-start",
|
|
181
|
+
end: "justify-items-end",
|
|
182
|
+
"end-safe": "justify-items-end-safe",
|
|
183
|
+
center: "justify-items-center",
|
|
184
|
+
"center-safe": "justify-items-center-safe",
|
|
185
|
+
stretch: "justify-items-stretch",
|
|
186
|
+
normal: "justify-items-normal",
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
Object.entries(justifyClasses).forEach(([justify, classes]) => {
|
|
190
|
+
const component = mount(UGrid, {
|
|
191
|
+
props: {
|
|
192
|
+
justify: justify as Props["justify"],
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
expect(component.attributes("class")).toContain(classes);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("Place Content – applies the correct place content class", () => {
|
|
201
|
+
const placeContentClasses = {
|
|
202
|
+
start: "place-content-start",
|
|
203
|
+
end: "place-content-end",
|
|
204
|
+
"end-safe": "place-content-end-safe",
|
|
205
|
+
center: "place-content-center",
|
|
206
|
+
"center-safe": "place-content-center-safe",
|
|
207
|
+
around: "place-content-around",
|
|
208
|
+
evenly: "place-content-evenly",
|
|
209
|
+
between: "place-content-between",
|
|
210
|
+
stretch: "place-content-stretch",
|
|
211
|
+
baseline: "place-content-baseline",
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
Object.entries(placeContentClasses).forEach(([placeContent, classes]) => {
|
|
215
|
+
const component = mount(UGrid, {
|
|
216
|
+
props: {
|
|
217
|
+
placeContent: placeContent as Props["placeContent"],
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
expect(component.attributes("class")).toContain(classes);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it("Place Items – applies the correct place items class", () => {
|
|
226
|
+
const placeItemsClasses = {
|
|
227
|
+
start: "place-items-start",
|
|
228
|
+
end: "place-items-end",
|
|
229
|
+
"end-safe": "place-items-end-safe",
|
|
230
|
+
center: "place-items-center",
|
|
231
|
+
"center-safe": "place-items-center-safe",
|
|
232
|
+
stretch: "place-items-stretch",
|
|
233
|
+
baseline: "place-items-baseline",
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
Object.entries(placeItemsClasses).forEach(([placeItems, classes]) => {
|
|
237
|
+
const component = mount(UGrid, {
|
|
238
|
+
props: {
|
|
239
|
+
placeItems: placeItems as Props["placeItems"],
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
expect(component.attributes("class")).toContain(classes);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it("Tag – renders the correct HTML tag", () => {
|
|
248
|
+
const tags = ["div", "section", "article", "main", "aside", "nav", "span"];
|
|
249
|
+
|
|
250
|
+
tags.forEach((tag) => {
|
|
251
|
+
const component = mount(UGrid, {
|
|
252
|
+
props: {
|
|
253
|
+
tag,
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
expect(component.element.tagName.toLowerCase()).toBe(tag);
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it("Data Test – applies the correct data-test attribute", () => {
|
|
262
|
+
const dataTest = "grid-test";
|
|
263
|
+
|
|
264
|
+
const component = mount(UGrid, {
|
|
265
|
+
props: {
|
|
266
|
+
dataTest,
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
expect(component.attributes("data-test")).toBe(dataTest);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
describe("Slots", () => {
|
|
275
|
+
it("Default – renders content from default slot", () => {
|
|
276
|
+
const slotContent = "Custom Content";
|
|
277
|
+
|
|
278
|
+
const component = mount(UGrid, {
|
|
279
|
+
slots: {
|
|
280
|
+
default: slotContent,
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
expect(component.text()).toContain(slotContent);
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
describe("Exposed refs", () => {
|
|
289
|
+
it("wrapperRef – exposes wrapperRef", () => {
|
|
290
|
+
const component = mount(UGrid);
|
|
291
|
+
|
|
292
|
+
expect(component.vm.wrapperRef).toBeDefined();
|
|
293
|
+
// wrapperRef is a reference to the wrapper div element, not a boolean
|
|
294
|
+
expect(component.vm.wrapperRef instanceof HTMLElement).toBe(true);
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
});
|