@code-coaching/vuetiful 0.13.0 → 0.13.2
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/dist/types/components/atoms/VRadio/VRadioDescription.test.d.ts +1 -0
- package/dist/types/components/atoms/VRadio/VRadioDescription.vue.d.ts +9 -3
- package/dist/types/components/atoms/VRadio/VRadioGroup.test.d.ts +1 -0
- package/dist/types/components/atoms/VRadio/VRadioGroup.vue.d.ts +24 -9
- package/dist/types/components/atoms/VRadio/VRadioItem.test.d.ts +1 -0
- package/dist/types/components/atoms/VRadio/VRadioItem.vue.d.ts +2 -2
- package/dist/types/components/atoms/VRadio/VRadioLabel.test.d.ts +1 -0
- package/dist/types/components/atoms/VRadio/VRadioLabel.vue.d.ts +3 -3
- package/dist/vuetiful.es.mjs +24 -13
- package/dist/vuetiful.umd.js +6 -6
- package/package.json +1 -1
- package/src/components/atoms/VRadio/VRadioDescription.test.ts +55 -0
- package/src/components/atoms/VRadio/VRadioDescription.vue +4 -1
- package/src/components/atoms/VRadio/VRadioGroup.test.ts +81 -0
- package/src/components/atoms/VRadio/VRadioGroup.vue +28 -17
- package/src/components/atoms/VRadio/VRadioItem.test.ts +183 -0
- package/src/components/atoms/VRadio/VRadioItem.vue +8 -8
- package/src/components/atoms/VRadio/VRadioLabel.test.ts +55 -0
- package/src/components/atoms/VRadio/VRadioLabel.vue +4 -6
package/package.json
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { mount } from "@vue/test-utils";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import VRadioGroup from "./VRadioGroup.vue";
|
|
4
|
+
import VRadioDescription from "./VRadioDescription.vue";
|
|
5
|
+
|
|
6
|
+
test("VRadioDescription using slot", () => {
|
|
7
|
+
const wrapper = mount({
|
|
8
|
+
template: `
|
|
9
|
+
<v-radio-group>
|
|
10
|
+
<v-radio-description>John Duck</v-radio-description>
|
|
11
|
+
</v-radio-group>
|
|
12
|
+
`,
|
|
13
|
+
components: {
|
|
14
|
+
"v-radio-description": VRadioDescription,
|
|
15
|
+
"v-radio-group": VRadioGroup,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
expect(wrapper.text()).toContain("John Duck");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe("VRadioDescription props", () => {
|
|
23
|
+
test("default 'as' prop", () => {
|
|
24
|
+
const wrapper = mount({
|
|
25
|
+
template: `
|
|
26
|
+
<v-radio-group>
|
|
27
|
+
<v-radio-label data-test="label">John Duck</v-radio-label>
|
|
28
|
+
</v-radio-group>
|
|
29
|
+
`,
|
|
30
|
+
components: {
|
|
31
|
+
"v-radio-label": VRadioDescription,
|
|
32
|
+
"v-radio-group": VRadioGroup,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const label = wrapper.find("[data-test='label']");
|
|
37
|
+
expect(label.element).toBeInstanceOf(HTMLParagraphElement);
|
|
38
|
+
});
|
|
39
|
+
test("custom 'as' prop", () => {
|
|
40
|
+
const wrapper = mount({
|
|
41
|
+
template: `
|
|
42
|
+
<v-radio-group>
|
|
43
|
+
<v-radio-label as="div" data-test="label">John Duck</v-radio-label>
|
|
44
|
+
</v-radio-group>
|
|
45
|
+
`,
|
|
46
|
+
components: {
|
|
47
|
+
"v-radio-label": VRadioDescription,
|
|
48
|
+
"v-radio-group": VRadioGroup,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const label = wrapper.find("[data-test='label']");
|
|
53
|
+
expect(label.element).toBeInstanceOf(HTMLDivElement);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { mount } from "@vue/test-utils";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import VRadioGroup from "./VRadioGroup.vue";
|
|
4
|
+
|
|
5
|
+
test("VRadioGroup using slot", () => {
|
|
6
|
+
const wrapper = mount(VRadioGroup, {
|
|
7
|
+
slots: {
|
|
8
|
+
default: "John Duck",
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
expect(wrapper.text()).toContain("John Duck");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("VRadioGroup default props", () => {
|
|
16
|
+
const wrapper = mount(VRadioGroup);
|
|
17
|
+
const radioGroupEl = wrapper.find("div");
|
|
18
|
+
expect(radioGroupEl.classes()).toEqual([
|
|
19
|
+
"radio-group",
|
|
20
|
+
"inline-flex",
|
|
21
|
+
"gap-1",
|
|
22
|
+
"p-1",
|
|
23
|
+
"bg-surface-200-700-token",
|
|
24
|
+
"text-surface-900",
|
|
25
|
+
"dark:text-surface-50",
|
|
26
|
+
"border-token",
|
|
27
|
+
"border-surface-400-500-token",
|
|
28
|
+
"rounded-container-token",
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
const radioGroup = wrapper.find("[data-test='radio-group']");
|
|
32
|
+
expect(radioGroup.element.tagName).toBe("DIV");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("VRadioGroup custom class props", () => {
|
|
36
|
+
const wrapper = mount(VRadioGroup, {
|
|
37
|
+
props: {
|
|
38
|
+
background: "custom-background-class",
|
|
39
|
+
text: "custom-text-class",
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
const radioGroupEl = wrapper.find("div");
|
|
43
|
+
expect(radioGroupEl.classes()).toEqual([
|
|
44
|
+
"radio-group",
|
|
45
|
+
"inline-flex",
|
|
46
|
+
"gap-1",
|
|
47
|
+
"p-1",
|
|
48
|
+
"custom-background-class",
|
|
49
|
+
"custom-text-class",
|
|
50
|
+
"border-token",
|
|
51
|
+
"border-surface-400-500-token",
|
|
52
|
+
"rounded-container-token",
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("VRadioGroup custom 'as' prop", () => {
|
|
57
|
+
const wrapper = mount(VRadioGroup, {
|
|
58
|
+
props: {
|
|
59
|
+
as: "span",
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const radioGroup = wrapper.find("[data-test='radio-group']");
|
|
64
|
+
expect(radioGroup.element.tagName).toBe("SPAN");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe("VRadioGroup v-model", () => {
|
|
68
|
+
describe("given value changes", () => {
|
|
69
|
+
test("should emit update:modelValue", async () => {
|
|
70
|
+
const wrapper = mount(VRadioGroup, {
|
|
71
|
+
props: {
|
|
72
|
+
modelValue: "John Duck",
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
wrapper.setProps({ modelValue: "Jane Duck" });
|
|
77
|
+
await wrapper.vm.$nextTick();
|
|
78
|
+
expect(wrapper.emitted()['update:modelValue'][0]).toEqual(["Jane Duck"]);
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
})
|
|
@@ -1,30 +1,40 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { RadioGroup } from
|
|
3
|
-
import { provide, ref, watch } from
|
|
2
|
+
import { RadioGroup } from "@headlessui/vue";
|
|
3
|
+
import { provide, ref, watch } from "vue";
|
|
4
4
|
|
|
5
|
-
const emit = defineEmits([
|
|
5
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
6
6
|
const props = defineProps({
|
|
7
|
-
as:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
as: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: "div",
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
disabled: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: false,
|
|
15
|
+
},
|
|
16
|
+
by: {
|
|
17
|
+
type: [String, Function],
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
modelValue: RadioGroup.props["modelValue"],
|
|
11
21
|
|
|
12
22
|
active: {
|
|
13
23
|
type: String,
|
|
14
|
-
default:
|
|
24
|
+
default: "variant-filled",
|
|
15
25
|
},
|
|
16
26
|
hover: {
|
|
17
27
|
type: String,
|
|
18
|
-
default:
|
|
28
|
+
default: "hover:variant-ghost",
|
|
19
29
|
},
|
|
20
30
|
|
|
21
31
|
background: {
|
|
22
32
|
type: String,
|
|
23
|
-
default:
|
|
33
|
+
default: "bg-surface-200-700-token",
|
|
24
34
|
},
|
|
25
35
|
text: {
|
|
26
36
|
type: String,
|
|
27
|
-
default:
|
|
37
|
+
default: "text-surface-900 dark:text-surface-50",
|
|
28
38
|
},
|
|
29
39
|
});
|
|
30
40
|
|
|
@@ -38,22 +48,23 @@ watch(
|
|
|
38
48
|
watch(
|
|
39
49
|
() => parentModelValue.value,
|
|
40
50
|
(newValue) => {
|
|
41
|
-
|
|
42
|
-
emit('update:modelValue', newValue);
|
|
51
|
+
emit("update:modelValue", newValue);
|
|
43
52
|
}
|
|
44
53
|
);
|
|
45
54
|
|
|
46
|
-
provide(
|
|
47
|
-
provide(
|
|
55
|
+
provide("active", props.active);
|
|
56
|
+
provide("hover", props.hover);
|
|
48
57
|
</script>
|
|
49
|
-
|
|
58
|
+
l
|
|
50
59
|
<template>
|
|
60
|
+
<!-- There is some odd behavior with test coverge, v-model must be the last property in this component -->
|
|
51
61
|
<radio-group
|
|
52
|
-
|
|
62
|
+
data-test="radio-group"
|
|
53
63
|
:as="as"
|
|
54
64
|
:disabled="disabled"
|
|
55
65
|
:by="by"
|
|
56
66
|
:class="`radio-group inline-flex gap-1 p-1 ${background} ${text} border-token border-surface-400-500-token rounded-container-token`"
|
|
67
|
+
v-model="parentModelValue"
|
|
57
68
|
>
|
|
58
69
|
<slot></slot>
|
|
59
70
|
</radio-group>
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { mount } from "@vue/test-utils";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import { ref } from "vue";
|
|
4
|
+
import VRadioGroup from "./VRadioGroup.vue";
|
|
5
|
+
import VRadioItem from "./VRadioItem.vue";
|
|
6
|
+
|
|
7
|
+
test("VRadioItem using slot", () => {
|
|
8
|
+
const wrapper = mount({
|
|
9
|
+
template: `
|
|
10
|
+
<v-radio-group>
|
|
11
|
+
<v-radio-item data-test="item" value="'John Duck'">John Duck</v-radio-item>
|
|
12
|
+
</v-radio-group>
|
|
13
|
+
`,
|
|
14
|
+
components: {
|
|
15
|
+
"v-radio-item": VRadioItem,
|
|
16
|
+
"v-radio-group": VRadioGroup,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const itemEl = wrapper.find("[data-test='item']").element;
|
|
21
|
+
expect(itemEl.textContent).toBe("John Duck");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("VRadioItem slot states", () => {
|
|
25
|
+
describe("given no injected provide", () => {
|
|
26
|
+
test("should have the default active class", () => {
|
|
27
|
+
const wrapper = mount({
|
|
28
|
+
setup() {
|
|
29
|
+
const value = ref("John Duck");
|
|
30
|
+
return { value };
|
|
31
|
+
},
|
|
32
|
+
template: `
|
|
33
|
+
<v-radio-group v-model="value">
|
|
34
|
+
<v-radio-item data-test="item" :value="'John Duck'">John Duck</v-radio-item>
|
|
35
|
+
</v-radio-group>
|
|
36
|
+
`,
|
|
37
|
+
components: {
|
|
38
|
+
"v-radio-item": VRadioItem,
|
|
39
|
+
"v-radio-group": VRadioGroup,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const itemEl = wrapper.find("[data-test='item']").find("span");
|
|
44
|
+
expect(itemEl.element.classList.contains("variant-filled")).toBe(true);
|
|
45
|
+
expect(itemEl.element.classList.contains("hover:variant-ghost")).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("should have the default hover class", () => {
|
|
49
|
+
const wrapper = mount({
|
|
50
|
+
setup() {
|
|
51
|
+
const value = ref("not John Duck");
|
|
52
|
+
return { value };
|
|
53
|
+
},
|
|
54
|
+
template: `
|
|
55
|
+
<v-radio-group v-model="value">
|
|
56
|
+
<v-radio-item data-test="item" :value="'John Duck'">John Duck</v-radio-item>
|
|
57
|
+
</v-radio-group>
|
|
58
|
+
`,
|
|
59
|
+
components: {
|
|
60
|
+
"v-radio-item": VRadioItem,
|
|
61
|
+
"v-radio-group": VRadioGroup,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const itemEl = wrapper.find("[data-test='item']").find("span");
|
|
66
|
+
expect(itemEl.element.classList.contains("variant-filled")).toBe(false);
|
|
67
|
+
expect(itemEl.element.classList.contains("hover:variant-ghost")).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
})
|
|
70
|
+
describe("given v-slot checked is true", () => {
|
|
71
|
+
test("should have the active class", () => {
|
|
72
|
+
const wrapper = mount({
|
|
73
|
+
setup() {
|
|
74
|
+
const value = ref("John Duck");
|
|
75
|
+
return { value };
|
|
76
|
+
},
|
|
77
|
+
template: `
|
|
78
|
+
<v-radio-group hover="custom-hover-class" active="custom-active-class" v-model="value">
|
|
79
|
+
<v-radio-item data-test="item" :value="'John Duck'">John Duck</v-radio-item>
|
|
80
|
+
</v-radio-group>
|
|
81
|
+
`,
|
|
82
|
+
components: {
|
|
83
|
+
"v-radio-item": VRadioItem,
|
|
84
|
+
"v-radio-group": VRadioGroup,
|
|
85
|
+
},
|
|
86
|
+
provide: {
|
|
87
|
+
active: "custom-active-class",
|
|
88
|
+
hover: "custom-hover-class",
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const itemEl = wrapper.find("[data-test='item']").find("span");
|
|
93
|
+
expect(itemEl.element.classList.contains("custom-active-class")).toBe(true);
|
|
94
|
+
expect(itemEl.element.classList.contains("custom-hover-class")).toBe(false);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe("given v-slot checked is false", () => {
|
|
99
|
+
test("should have the hover class", () => {
|
|
100
|
+
const wrapper = mount({
|
|
101
|
+
setup() {
|
|
102
|
+
const value = ref("not John Duck");
|
|
103
|
+
return { value };
|
|
104
|
+
},
|
|
105
|
+
template: `
|
|
106
|
+
<v-radio-group hover="custom-hover-class" active="custom-active-class" v-model="value">
|
|
107
|
+
<v-radio-item data-test="item" :value="'John Duck'">John Duck</v-radio-item>
|
|
108
|
+
</v-radio-group>
|
|
109
|
+
`,
|
|
110
|
+
components: {
|
|
111
|
+
"v-radio-item": VRadioItem,
|
|
112
|
+
"v-radio-group": VRadioGroup,
|
|
113
|
+
},
|
|
114
|
+
provide: {
|
|
115
|
+
active: "custom-active-class",
|
|
116
|
+
hover: "custom-hover-class",
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const itemEl = wrapper.find("[data-test='item']").find("span");
|
|
121
|
+
expect(itemEl.element.classList.contains("custom-active-class")).toBe(false);
|
|
122
|
+
expect(itemEl.element.classList.contains("custom-hover-class")).toBe(true);
|
|
123
|
+
});
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
describe("given v-slot disabled is false", () => {
|
|
127
|
+
test("should not have the disabled classes", () => {
|
|
128
|
+
const wrapper = mount({
|
|
129
|
+
setup() {
|
|
130
|
+
const value = ref("John Duck");
|
|
131
|
+
return { value };
|
|
132
|
+
},
|
|
133
|
+
template: `
|
|
134
|
+
<v-radio-group hover="custom-hover-class" active="custom-active-class" v-model="value">
|
|
135
|
+
<v-radio-item data-test="item" :value="'not John Duck'">John Duck</v-radio-item>
|
|
136
|
+
</v-radio-group>
|
|
137
|
+
`,
|
|
138
|
+
components: {
|
|
139
|
+
"v-radio-item": VRadioItem,
|
|
140
|
+
"v-radio-group": VRadioGroup,
|
|
141
|
+
},
|
|
142
|
+
provide: {
|
|
143
|
+
active: "custom-active-class",
|
|
144
|
+
hover: "custom-hover-class",
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const itemEl = wrapper.find("[data-test='item']").find("span");
|
|
149
|
+
expect(itemEl.element.classList.contains("cursor-pointer")).toBe(true);
|
|
150
|
+
expect(itemEl.element.classList.contains("cursor-not-allowed")).toBe(false);
|
|
151
|
+
expect(itemEl.element.classList.contains("opacity-50")).toBe(false);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
describe("given v-slot disabled is true", () => {
|
|
156
|
+
test("should have the disabled classes", () => {
|
|
157
|
+
const wrapper = mount({
|
|
158
|
+
setup() {
|
|
159
|
+
const value = ref("John Duck");
|
|
160
|
+
return { value };
|
|
161
|
+
},
|
|
162
|
+
template: `
|
|
163
|
+
<v-radio-group hover="custom-hover-class" active="custom-active-class" v-model="value">
|
|
164
|
+
<v-radio-item disabled data-test="item" :value="'not John Duck'">John Duck</v-radio-item>
|
|
165
|
+
</v-radio-group>
|
|
166
|
+
`,
|
|
167
|
+
components: {
|
|
168
|
+
"v-radio-item": VRadioItem,
|
|
169
|
+
"v-radio-group": VRadioGroup,
|
|
170
|
+
},
|
|
171
|
+
provide: {
|
|
172
|
+
active: "custom-active-class",
|
|
173
|
+
hover: "custom-hover-class",
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const itemEl = wrapper.find("[data-test='item']").find("span");
|
|
178
|
+
expect(itemEl.element.classList.contains("cursor-pointer")).toBe(false);
|
|
179
|
+
expect(itemEl.element.classList.contains("cursor-not-allowed")).toBe(true);
|
|
180
|
+
expect(itemEl.element.classList.contains("opacity-50")).toBe(true);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
});
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { RadioGroupOption } from
|
|
3
|
-
import { inject } from
|
|
2
|
+
import { RadioGroupOption } from "@headlessui/vue";
|
|
3
|
+
import { inject } from "vue";
|
|
4
4
|
|
|
5
5
|
defineProps({
|
|
6
6
|
value: {
|
|
7
|
-
type: [String, Number],
|
|
7
|
+
type: [String, Number, Boolean, Object],
|
|
8
8
|
required: true,
|
|
9
9
|
},
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
const active = (inject(
|
|
13
|
-
const hover = (inject(
|
|
12
|
+
const active = (inject("active") as string);
|
|
13
|
+
const hover = (inject("hover") as string);
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
16
|
<template>
|
|
17
17
|
<RadioGroupOption v-slot="{ checked, disabled }" :value="value">
|
|
18
18
|
<span
|
|
19
|
-
:class="`radio-item px-4 py-1 text-center text-base rounded-token ${
|
|
20
|
-
|
|
21
|
-
}`"
|
|
19
|
+
:class="`radio-item px-4 py-1 text-center text-base rounded-token ${
|
|
20
|
+
checked ? active : hover
|
|
21
|
+
} ${disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer'}`"
|
|
22
22
|
>
|
|
23
23
|
<slot />
|
|
24
24
|
</span>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { mount } from "@vue/test-utils";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import VRadioGroup from "./VRadioGroup.vue";
|
|
4
|
+
import VRadioLabel from "./VRadioLabel.vue";
|
|
5
|
+
|
|
6
|
+
test("VRadioLabel using slot", () => {
|
|
7
|
+
const wrapper = mount({
|
|
8
|
+
template: `
|
|
9
|
+
<v-radio-group>
|
|
10
|
+
<v-radio-label>John Duck</v-radio-label>
|
|
11
|
+
</v-radio-group>
|
|
12
|
+
`,
|
|
13
|
+
components: {
|
|
14
|
+
"v-radio-label": VRadioLabel,
|
|
15
|
+
"v-radio-group": VRadioGroup,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
expect(wrapper.text()).toContain("John Duck");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe("VRadioLabel props", () => {
|
|
23
|
+
test("default 'as' prop", () => {
|
|
24
|
+
const wrapper = mount({
|
|
25
|
+
template: `
|
|
26
|
+
<v-radio-group>
|
|
27
|
+
<v-radio-label data-test="label">John Duck</v-radio-label>
|
|
28
|
+
</v-radio-group>
|
|
29
|
+
`,
|
|
30
|
+
components: {
|
|
31
|
+
"v-radio-label": VRadioLabel,
|
|
32
|
+
"v-radio-group": VRadioGroup,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const label = wrapper.find("[data-test='label']");
|
|
37
|
+
expect(label.element).toBeInstanceOf(HTMLParagraphElement);
|
|
38
|
+
});
|
|
39
|
+
test("custom 'as' prop", () => {
|
|
40
|
+
const wrapper = mount({
|
|
41
|
+
template: `
|
|
42
|
+
<v-radio-group>
|
|
43
|
+
<v-radio-label as="div" data-test="label">John Duck</v-radio-label>
|
|
44
|
+
</v-radio-group>
|
|
45
|
+
`,
|
|
46
|
+
components: {
|
|
47
|
+
"v-radio-label": VRadioLabel,
|
|
48
|
+
"v-radio-group": VRadioGroup,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const label = wrapper.find("[data-test='label']");
|
|
53
|
+
expect(label.element).toBeInstanceOf(HTMLDivElement);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { RadioGroupLabel } from
|
|
2
|
+
import { RadioGroupLabel } from "@headlessui/vue";
|
|
3
3
|
|
|
4
4
|
defineProps({
|
|
5
5
|
as: {
|
|
6
|
-
type:
|
|
7
|
-
default:
|
|
8
|
-
}
|
|
6
|
+
type: String,
|
|
7
|
+
default: "p",
|
|
8
|
+
},
|
|
9
9
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
10
|
</script>
|
|
13
11
|
|
|
14
12
|
<template>
|