@volverjs/ui-vue 0.0.1-beta.11 → 0.0.1-beta.12

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.
Files changed (81) hide show
  1. package/dist/components/VvBadge/VvBadge.d.ts +1 -1
  2. package/dist/components/VvBadge/VvBadge.es.js +165 -12
  3. package/dist/components/VvBadge/VvBadge.umd.js +1 -1
  4. package/dist/components/VvBadge/VvBadge.vue.d.ts +4 -4
  5. package/dist/components/VvBreadcrumb/VvBreadcrumb.d.ts +1 -1
  6. package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +4 -4
  7. package/dist/components/VvButton/VvButton.d.ts +2 -33
  8. package/dist/components/VvButton/VvButton.es.js +183 -198
  9. package/dist/components/VvButton/VvButton.umd.js +1 -1
  10. package/dist/components/VvButton/VvButton.vue.d.ts +9 -44
  11. package/dist/components/VvButton/useButtonGroupProps.d.ts +1 -6
  12. package/dist/components/VvButtonGroup/VvButtonGroup.d.ts +2 -26
  13. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +68 -78
  14. package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
  15. package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +9 -69
  16. package/dist/components/VvDropdown/VvDropdown.d.ts +1 -1
  17. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +4 -4
  18. package/dist/components/VvInputText/VvInputText.d.ts +1 -1
  19. package/dist/components/VvInputText/VvInputText.vue.d.ts +4 -4
  20. package/dist/components/VvProgress/VvProgress.d.ts +1 -1
  21. package/dist/components/VvProgress/VvProgress.vue.d.ts +4 -4
  22. package/dist/components/VvSelect/VvSelect.d.ts +5 -1
  23. package/dist/components/VvSelect/VvSelect.es.js +395 -207
  24. package/dist/components/VvSelect/VvSelect.umd.js +2 -2
  25. package/dist/components/VvSelect/VvSelect.vue.d.ts +12 -5
  26. package/dist/components/VvTextarea/VvTextarea.d.ts +1 -1
  27. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +4 -4
  28. package/dist/components/index.es.js +579 -610
  29. package/dist/components/index.umd.js +2 -2
  30. package/dist/composables/group/types/IButtonGroupState.d.ts +4 -0
  31. package/dist/icons.es.js +3 -3
  32. package/dist/icons.umd.js +1 -1
  33. package/dist/index.es.js +553 -585
  34. package/dist/index.umd.js +2 -2
  35. package/dist/props/index.d.ts +2 -1
  36. package/dist/stories/RadioGroup/RadioOption.test.d.ts +4 -0
  37. package/dist/stories/RadioGroup/RadioProperty.test.d.ts +1 -1
  38. package/dist/stories/RadioGroup/RadioSlots.test.d.ts +6 -0
  39. package/package.json +2 -2
  40. package/src/assets/icons/detailed.json +1 -1
  41. package/src/assets/icons/normal.json +1 -1
  42. package/src/assets/icons/simple.json +1 -1
  43. package/src/components/VvBadge/VvBadge.ts +4 -2
  44. package/src/components/VvBadge/VvBadge.vue +8 -3
  45. package/src/components/VvButton/VvButton.ts +4 -34
  46. package/src/components/VvButton/VvButton.vue +3 -12
  47. package/src/components/VvButton/useButtonGroupProps.ts +3 -11
  48. package/src/components/VvButtonGroup/VvButtonGroup.ts +4 -17
  49. package/src/components/VvButtonGroup/VvButtonGroup.vue +5 -16
  50. package/src/components/VvSelect/VvSelect.ts +5 -1
  51. package/src/components/VvSelect/VvSelect.vue +7 -1
  52. package/src/composables/group/types/IButtonGroupState.ts +4 -0
  53. package/src/props/index.ts +3 -1
  54. package/src/stories/Badge/BadgeColor.stories.mdx +4 -4
  55. package/src/stories/Badge/BadgeModifiers.stories.mdx +65 -0
  56. package/src/stories/Button/ButtonActive.stories.mdx +27 -0
  57. package/src/stories/Button/ButtonDisabled.stories.mdx +28 -0
  58. package/src/stories/Button/ButtonIconPosition.stories.mdx +0 -1
  59. package/src/stories/Button/ButtonModifiers.stories.mdx +103 -46
  60. package/src/stories/Button/ButtonSelected.stories.mdx +30 -0
  61. package/src/stories/ButtonGroup/ButtonGroupAction.stories.mdx +2 -2
  62. package/src/stories/ButtonGroup/ButtonGroupActionQuiet.stories.mdx +2 -2
  63. package/src/stories/ButtonGroup/ButtonGroupBlock.stories.mdx +1 -1
  64. package/src/stories/ButtonGroup/ButtonGroupRounded.stories.mdx +1 -1
  65. package/src/stories/RadioGroup/RadioGroupHintLabel.stories.mdx +6 -6
  66. package/src/stories/RadioGroup/RadioGroupLabel.stories.mdx +7 -2
  67. package/src/stories/RadioGroup/RadioGroupOptionLabel.stories.mdx +7 -19
  68. package/src/stories/RadioGroup/RadioGroupOptionValue.stories.mdx +7 -19
  69. package/src/stories/RadioGroup/RadioGroupOptions.stories.mdx +3 -17
  70. package/src/stories/RadioGroup/RadioGroupSlots.stories.mdx +10 -9
  71. package/src/stories/RadioGroup/RadioOption.test.ts +45 -0
  72. package/src/stories/RadioGroup/RadioProperty.test.ts +4 -4
  73. package/src/stories/RadioGroup/RadioSlots.test.ts +29 -0
  74. package/src/stories/Select/SelectNative.stories.mdx +45 -0
  75. package/src/stories/stories.scss +5 -27
  76. package/src/stories/Button/ButtonVariant.stories.mdx +0 -205
  77. package/src/stories/Button/test.js +0 -41
  78. package/src/stories/Radio/RadioTest.js +0 -90
  79. package/src/stories/RadioGroup/RadioOptionsTest.js +0 -78
  80. package/src/stories/RadioGroup/RadioPropertyTest.js +0 -131
  81. package/src/stories/RadioGroup/RadioSlotsTest.js +0 -20
@@ -0,0 +1,45 @@
1
+ import { Canvas, Meta, Story, Source } from '@storybook/addon-docs'
2
+ import VvSelect from '../../components/VvSelect/VvSelect.vue'
3
+ import { Template } from './Select.stories.mdx'
4
+ import { VvSelectProps } from '../../components/VvSelect/VvSelect'
5
+ import ObjectUtilities from '../../utils/ObjectUtilities'
6
+
7
+ <Meta title="Components/Select/Props/native" />
8
+
9
+ # VvSelect native
10
+
11
+ Let's define a story for our `native` select.
12
+
13
+ <Canvas>
14
+ <Story
15
+ name="native"
16
+ args={{
17
+ ...ObjectUtilities.propsToObject(VvSelectProps),
18
+ maxValues: -1,
19
+ label: 'Lorem Ipsum',
20
+ placeholder: 'Placeholder',
21
+ options: [
22
+ {
23
+ label: 'Option 1',
24
+ value: 1
25
+ },
26
+ {
27
+ label: 'Option 2',
28
+ value: 2
29
+ },
30
+ {
31
+ label: 'Option 3',
32
+ value: 3
33
+ }
34
+ ],
35
+ native: true,
36
+ value: ''
37
+ }}>
38
+ {Template.bind()}
39
+ </Story>
40
+ </Canvas>
41
+
42
+ <Source
43
+ language="html"
44
+ code={`<vv-select v-model:modelValue="value" :options="options" placeholder="Placeholder" label="Label 1" native />`}
45
+ />
@@ -1,35 +1,13 @@
1
- $zero-specificity-for-utilities: false;
2
-
3
- @import '@volverjs/style/scss/reset';
4
- @import '@volverjs/style/scss/props';
5
- @import '@volverjs/style/scss/themes/dark';
6
- @import '@volverjs/style/scss/utilities';
7
-
8
- // components
9
- @import '@volverjs/style/scss/components/vv-accordion';
10
- @import '@volverjs/style/scss/components/vv-badge';
11
- @import '@volverjs/style/scss/components/vv-button';
12
- @import '@volverjs/style/scss/components/vv-button-group';
13
- @import '@volverjs/style/scss/components/vv-input-checkbox';
14
- @import '@volverjs/style/scss/components/vv-input-checkbox-group';
15
- @import '@volverjs/style/scss/components/vv-input-text';
16
- @import '@volverjs/style/scss/components/vv-progress';
17
- @import '@volverjs/style/scss/components/vv-input-radio';
18
- @import '@volverjs/style/scss/components/vv-input-radio-group';
19
- @import '@volverjs/style/scss/components/vv-dialog';
20
- @import '@volverjs/style/scss/components/vv-select';
21
- @import '@volverjs/style/scss/components/vv-dropdown';
22
- @import '@volverjs/style/scss/components/vv-card';
23
- @import '@volverjs/style/scss/components/vv-textarea';
24
- @import '@volverjs/style/scss/components/vv-breadcrumb';
25
-
1
+ // $zero-specificity-for-utilities: false;
2
+ @use '@volverjs/style/scss';
3
+ @use '@volverjs/style/scss/themes/dark';
26
4
 
27
5
  //Custom classes for stories
28
6
  .vv-textarea {
29
- &--variante-1{
7
+ &--variante-1 {
30
8
  --vv-textarea-element-input-color: red;
31
9
  }
32
- &--variante-2{
10
+ &--variante-2 {
33
11
  --vv-textarea-element-wrapper-background-color: green;
34
12
  }
35
13
  }
@@ -1,205 +0,0 @@
1
- import { Canvas, Meta, Story, Source } from '@storybook/addon-docs'
2
- import VvButton from '../../components/VvButton/VvButton.vue'
3
- import { buttonTest, classTest, cssTest, disableTest } from './test.js'
4
- import { testButton } from './Button.test'
5
-
6
- <Meta title="Components/Button/Variant" />
7
-
8
- # VvButton variant
9
-
10
- Stories of `VvButton` default `variant`.
11
-
12
- ## Block
13
-
14
- Let's define a story for our `block` button.
15
- Create block level button that span the full width of a parent.
16
-
17
- <Canvas>
18
- <Story
19
- name="block"
20
- play={async (ctx) => {
21
- testButton(ctx, {
22
- className: `vv-button--block`
23
- })
24
- }}>
25
- {() => {
26
- return {
27
- components: { VvButton },
28
- template: `<vv-button label="Block" block />`
29
- }
30
- }}
31
- </Story>
32
- </Canvas>
33
-
34
- <Source language="jsx" code={'<vv-button label="Block" block />'} />
35
-
36
- ## Rounded
37
-
38
- Let's define a story for our `rounded` button:
39
-
40
- <Canvas>
41
- <Story
42
- name="rounded"
43
- play={async (ctx) => {
44
- testButton(ctx, {
45
- className: `vv-button--rounded`
46
- })
47
- }}>
48
- {() => {
49
- return {
50
- components: { VvButton },
51
- template: `<vv-button label="Rounded" rounded />`
52
- }
53
- }}
54
- </Story>
55
- </Canvas>
56
-
57
- <Source language="jsx" code={'<vv-button label="Rounded" rounded />'} />
58
-
59
- ## Full-bleed
60
-
61
- Let's define a story for our `full-bleed` button:
62
-
63
- <Canvas>
64
- <Story
65
- name="full-bleed"
66
- play={async (ctx) => {
67
- testButton(ctx, {
68
- className: `vv-button--full-bleed`
69
- })
70
- }}>
71
- {() => {
72
- return {
73
- components: { VvButton },
74
- template: `<div class="flex gap-4">
75
- <vv-button label="Full bleed" full-bleed />
76
- </div>`
77
- }
78
- }}
79
- </Story>
80
- </Canvas>
81
-
82
- <Source
83
- language="jsx"
84
- code={`<div class="flex gap-4">
85
- <vv-button label="Full bleed" full-bleed />
86
- </div>`}
87
- />
88
-
89
- ## Disabled
90
-
91
- Let's define a story for our `disabled` button.
92
-
93
- <Canvas>
94
- <Story
95
- name="disabled"
96
- play={async (ctx) => {
97
- testButton(ctx, {
98
- isClickDisabled: true
99
- })
100
- }}>
101
- {() => {
102
- return {
103
- components: { VvButton },
104
- template: `<vv-button label="Disabled" disabled />`
105
- }
106
- }}
107
- </Story>
108
- </Canvas>
109
-
110
- <Source language="jsx" code={'<vv-button label="Disabled" disabled />'} />
111
-
112
- ## Active
113
-
114
- Let's define a story for our `active` button.
115
-
116
- <Canvas>
117
- <Story
118
- name="active"
119
- play={async (ctx) => {
120
- testButton(ctx, {
121
- className: 'vv-button--active'
122
- })
123
- }}>
124
- {() => {
125
- return {
126
- components: { VvButton },
127
- template: `<vv-button label="Active" active />`
128
- }
129
- }}
130
- </Story>
131
- </Canvas>
132
-
133
- <Source language="jsx" code={'<vv-button label="Active" active />'} />
134
-
135
- ## Action
136
-
137
- Let's define a story for our `action` button.
138
-
139
- <Canvas>
140
- <Story
141
- name="action"
142
- play={async (ctx) => {
143
- testButton(ctx, {
144
- className: 'vv-button--action'
145
- })
146
- }}>
147
- {() => {
148
- return {
149
- components: { VvButton },
150
- template: `<vv-button label="Action" action />`
151
- }
152
- }}
153
- </Story>
154
- </Canvas>
155
-
156
- <Source language="jsx" code={'<vv-button label="Action" action />'} />
157
-
158
- ## Action Selected
159
-
160
- Let's define a story for our `action` `selected` button.
161
-
162
- <Canvas>
163
- <Story
164
- name="selected"
165
- play={async (ctx) => {
166
- testButton(ctx, {
167
- className: 'vv-button--selected'
168
- })
169
- }}>
170
- {() => {
171
- return {
172
- components: { VvButton },
173
- template: `<vv-button label="Action Selected" action selected />`
174
- }
175
- }}
176
- </Story>
177
- </Canvas>
178
-
179
- <Source language="jsx" code={'<vv-button label="Action" action selected />'} />
180
-
181
- ## Action quiet
182
-
183
- Let's define a story for our `action-quiet` button.
184
-
185
- <Canvas>
186
- <Story
187
- name="action-quiet"
188
- play={async (ctx) => {
189
- testButton(ctx, {
190
- className: 'vv-button--action-quiet'
191
- })
192
- }}>
193
- {() => {
194
- return {
195
- components: { VvButton },
196
- template: `<vv-button label="Action quiet" action-quiet />`
197
- }
198
- }}
199
- </Story>
200
- </Canvas>
201
-
202
- <Source
203
- language="jsx"
204
- code={'<vv-button label="Action quiet" action-quiet />'}
205
- />
@@ -1,41 +0,0 @@
1
- import { expect } from '@storybook/jest'
2
- import { userEvent, within } from '@storybook/testing-library'
3
- import { toHaveNoViolations, axe } from 'jest-axe'
4
-
5
- async function buttonTest({ canvasElement, functions, ...args }) {
6
- const button = await within(canvasElement).findByRole('button')
7
- await userEvent.click(button)
8
-
9
- if (functions) {
10
- functions.forEach(async (func) => {
11
- await func({ button: button, ...args })
12
- })
13
- }
14
-
15
- // Accessibility Test
16
- expect.extend(toHaveNoViolations)
17
- expect(await axe(button)).toHaveNoViolations()
18
- }
19
-
20
- async function classTest({ button, className = null }) {
21
- if (className) {
22
- expect(button).toHaveClass(`vv-button--${className}`)
23
- }
24
- }
25
-
26
- async function cssTest({ button, cssString = null }) {
27
- if (cssString) {
28
- expect(button).toHaveStyle(cssString)
29
- }
30
- }
31
- async function disableTest({ button }) {
32
- expect(button).toBeDisabled()
33
- }
34
-
35
- async function propertyTest({ button, properties = [] }) {
36
- properties.forEach((property) => {
37
- expect(button).toHaveProperty(property)
38
- })
39
- }
40
-
41
- export { buttonTest, classTest, cssTest, disableTest, propertyTest }
@@ -1,90 +0,0 @@
1
- /* eslint-disable no-console */
2
- import { expect } from '@storybook/jest'
3
- import { userEvent } from '@storybook/testing-library'
4
- import { toHaveNoViolations, axe } from 'jest-axe'
5
-
6
- async function disabledTest() {
7
- const radioInput = document.getElementById('1')
8
- console.log({ radioInput })
9
- await expect(radioInput).toHaveClass('vv-input-radio__input--disabled')
10
- await expect(radioInput).toBeDisabled()
11
- await expect(radioInput).toHaveProperty('disabled')
12
- await expect(radioInput).not.toBeChecked()
13
- await accessibilityTest(radioInput)
14
- }
15
-
16
- async function invalidTest() {
17
- const radioInput = document.getElementById('6')
18
- console.log(radioInput.parentElement)
19
- await expect(radioInput.parentElement).toHaveClass(
20
- 'vv-input-radio--invalid'
21
- )
22
- accessibilityTest(radioInput)
23
- }
24
-
25
- async function errorWithSingleMessageTest() {
26
- const radioInput = document.getElementById('7')
27
- await expect(radioInput.parentElement).toHaveClass(
28
- 'vv-input-radio--invalid'
29
- )
30
- const errorMessage = radioInput.labels[0].childNodes[4].innerHTML
31
- expect(errorMessage).toBe('Sbagliato!')
32
- accessibilityTest(radioInput)
33
- }
34
-
35
- async function errorWithMultipleMessagesTest() {
36
- const radioInput = document.getElementById('8')
37
- await expect(radioInput.parentElement).toHaveClass(
38
- 'vv-input-radio--invalid'
39
- )
40
- // expect(errorMessage).toBe('Sbagliato!')
41
- console.log(radioInput.labels)
42
- accessibilityTest(radioInput)
43
- }
44
-
45
- async function switchTest() {
46
- const radioInput = document.getElementById('3')
47
- await expect(radioInput.parentElement).toHaveClass(
48
- 'vv-input-checkbox--switch'
49
- )
50
- userEvent.click(radioInput)
51
- await expect(radioInput).toBeChecked()
52
- console.log(radioInput.parentElement)
53
- accessibilityTest(radioInput)
54
- }
55
-
56
- expect.extend({
57
- async toBeChecked(radioInput) {
58
- let result = {
59
- pass: false,
60
- message: `Click event doesn't work`
61
- }
62
- // await userEvent.click(radioInput)
63
- await radioInput.click()
64
- if (radioInput.checked) {
65
- result = {
66
- pass: true,
67
- message: `Click event work!`
68
- }
69
- }
70
- return result
71
- }
72
- })
73
-
74
- async function classTest(input, classNames = []) {
75
- classNames.forEach((cssClass) => {
76
- expect(input).toHaveClass(cssClass)
77
- })
78
- }
79
-
80
- async function accessibilityTest(element) {
81
- expect.extend(toHaveNoViolations)
82
- expect(await axe(element)).toHaveNoViolations()
83
- }
84
-
85
- export {
86
- disabledTest,
87
- invalidTest,
88
- errorWithSingleMessageTest,
89
- errorWithMultipleMessagesTest
90
- }
@@ -1,78 +0,0 @@
1
- import { expect } from '@storybook/jest'
2
-
3
- async function mainOptionsTest({ functions, ...data }) {
4
- const options = data.args.options
5
- options.forEach((option, index) => {
6
- const radio = document.getElementById(`options_opt${index}`)
7
- const radioValue = radio._value
8
- const radioLabel = radio.parentElement.innerText
9
- functions.forEach(async (func) => {
10
- await func({ ...data }, index, radioValue, radioLabel)
11
- })
12
- })
13
- }
14
-
15
- async function radioOptionsTest({ ...data }, index, radioValue, radioLabel) {
16
- const optionValue = data.args.options[index].value
17
- const optionLabel = data.args.options[index].label
18
- expect(optionLabel).toEqual(radioLabel)
19
- expect(optionValue).toEqual(radioValue)
20
- }
21
-
22
- async function arrayOptionsTest({ ...data }, index, radioValue, radioLabel) {
23
- const optionValue = data.args.options[index]
24
- expect(optionValue).toEqual(radioLabel)
25
- expect(optionValue).toEqual(radioValue)
26
- }
27
-
28
- async function optionsValueStringTest(
29
- { ...data },
30
- index,
31
- radioValue,
32
- radioLabel
33
- ) {
34
- const optionValue = data.args.options[index].qta
35
- const optionLabel = data.args.options[index].label
36
- expect(optionLabel).toEqual(radioLabel)
37
- expect(optionValue).toEqual(radioValue)
38
- }
39
-
40
- async function optionsValueFunctionTest({ ...data }, index, radioValue) {
41
- const optionValue = data.args.options[index].qta
42
- const optionLabel = data.args.options[index].label
43
- const resultValue = `${optionValue}_${optionLabel}`
44
- expect(radioValue).toEqual(resultValue)
45
- }
46
-
47
- async function optionsLabelStringTest(
48
- { ...data },
49
- index,
50
- radioValue,
51
- radioLabel
52
- ) {
53
- const optionValue = data.args.options[index].value
54
- const optionLabel = data.args.options[index].name
55
- expect(optionLabel).toEqual(radioLabel)
56
- expect(optionValue).toEqual(radioValue)
57
- }
58
-
59
- async function optionsLabelFunctionTest(
60
- { ...data },
61
- index,
62
- radioValue,
63
- radioLabel
64
- ) {
65
- const optionLabel = data.args.options[index].name
66
- const resultLabel = `Frutto: ${optionLabel}`
67
- expect(radioLabel).toEqual(resultLabel)
68
- }
69
-
70
- export {
71
- mainOptionsTest,
72
- radioOptionsTest,
73
- arrayOptionsTest,
74
- optionsValueStringTest,
75
- optionsValueFunctionTest,
76
- optionsLabelStringTest,
77
- optionsLabelFunctionTest
78
- }
@@ -1,131 +0,0 @@
1
- import { expect } from '@storybook/jest'
2
- import { userEvent, within } from '@storybook/testing-library'
3
- import { toHaveNoViolations, axe } from 'jest-axe'
4
-
5
- async function radioGroupTest({ canvasElement }) {
6
- const radioGroupParent = await within(canvasElement).findByRole(
7
- 'radiogroup'
8
- )
9
- const radio1 = document.getElementById('o1')
10
- const radio2 = document.getElementById('o2')
11
- radioCheck(radio1, false)
12
- await expect(radio1).toBeClicked()
13
- classTest(radioGroupParent, [
14
- 'vv-input-radio-group',
15
- 'vv-input-radio-group--horizontal'
16
- ])
17
- classTest(radio1, ['focus-visible', 'vv-input-radio__input--checked'])
18
- radioCheck(radio1, true)
19
- radioCheck(radio2, false)
20
- accessibilityTest(radioGroupParent)
21
- }
22
-
23
- async function disabledTest() {
24
- const radio = document.getElementById('disabled_opt0')
25
- expect(radio).toHaveClass('vv-input-radio__input--disabled')
26
- expect(radio).toBeDisabled()
27
- await radioCheck(radio, false)
28
- await userEvent.click(radio)
29
- await expect(radio).not.toBeClicked()
30
- await radioCheck(radio, false)
31
- accessibilityTest(radio.parentElement)
32
- }
33
-
34
- async function errorLabelTest({ canvasElement }) {
35
- const radioGroupParent = await within(canvasElement).findByRole(
36
- 'radiogroup'
37
- )
38
- expect(radioGroupParent).toHaveClass('vv-input-radio-group--invalid')
39
- accessibilityTest(radioGroupParent)
40
- }
41
-
42
- async function hintLabelTest({ canvasElement, ...data }) {
43
- const radioGroupParent = await within(canvasElement).findByRole(
44
- 'radiogroup'
45
- )
46
- const labelInnerHTML = radioGroupParent.lastChild.innerHTML
47
- const hintLabel = data.args.hintLabel
48
- expect(labelInnerHTML).toBeTruthy()
49
- expect(hintLabel).toBeTruthy()
50
- expect(labelInnerHTML).toEqual(hintLabel)
51
- }
52
-
53
- async function labelTest({ canvasElement, ...data }) {
54
- const radioGroupParent = await within(canvasElement).findByRole(
55
- 'radiogroup'
56
- )
57
- const labelInnerHTML = radioGroupParent.firstChild.innerHTML
58
- const hintLabel = data.args.label
59
- expect(labelInnerHTML).toBeTruthy()
60
- expect(hintLabel).toBeTruthy()
61
- expect(labelInnerHTML).toEqual(hintLabel)
62
- }
63
-
64
- async function readonlyTest() {
65
- const radios = ['readonly_opt0', 'readonly_opt1', 'readonly_opt2']
66
- radios.forEach((radio) => {
67
- expect(document.getElementById(radio)).toHaveClass(
68
- 'vv-input-radio__input--readonly'
69
- )
70
- })
71
- }
72
-
73
- async function validTest({ canvasElement }) {
74
- const radioGroupParent = await within(canvasElement).findByRole(
75
- 'radiogroup'
76
- )
77
- expect(radioGroupParent).toHaveClass('vv-input-radio-group--valid')
78
- accessibilityTest(radioGroupParent)
79
- }
80
-
81
- async function verticalTest({ canvasElement }) {
82
- const radioGroupParent = await within(canvasElement).findByRole(
83
- 'radiogroup'
84
- )
85
- expect(radioGroupParent).not.toHaveClass('vv-input-radio-group--horizontal')
86
- }
87
-
88
- expect.extend({
89
- async toBeClicked(radioInput) {
90
- let result = {
91
- pass: false,
92
- message: `Click event doesn't work`
93
- }
94
- await userEvent.click(radioInput)
95
- await radioInput.click()
96
- if (radioInput.checked) {
97
- result = {
98
- pass: true,
99
- message: `Click event work!`
100
- }
101
- }
102
- return result
103
- }
104
- })
105
-
106
- async function classTest(input, classNames = []) {
107
- classNames.forEach((cssClass) => {
108
- expect(input).toHaveClass(cssClass)
109
- })
110
- }
111
-
112
- async function accessibilityTest(element) {
113
- expect.extend(toHaveNoViolations)
114
- expect(await axe(element)).toHaveNoViolations()
115
- }
116
-
117
- async function radioCheck(radio, value) {
118
- expect(radio.ariaChecked).toBe(`${value}`)
119
- expect(radio.checked).toBe(value)
120
- }
121
-
122
- export {
123
- radioGroupTest,
124
- errorLabelTest,
125
- hintLabelTest,
126
- labelTest,
127
- disabledTest,
128
- readonlyTest,
129
- validTest,
130
- verticalTest
131
- }
@@ -1,20 +0,0 @@
1
- import { expect } from '@storybook/jest'
2
- import { within } from '@storybook/testing-library'
3
- import { toHaveNoViolations, axe } from 'jest-axe'
4
-
5
- async function slotsTest({ canvasElement }, radioGroup) {
6
- const radioGroupParent = await within(canvasElement).findByRole(
7
- 'radiogroup'
8
- )
9
- const slot = radioGroupParent.lastElementChild
10
- expect(slot).toHaveClass('vv-input-radio-group__hint')
11
- expect(slot.innerText).toBeTruthy
12
- if (radioGroup) {
13
- expect(radioGroupParent).toHaveClass(
14
- `vv-input-radio-group--${radioGroup}`
15
- )
16
- }
17
- expect.extend(toHaveNoViolations)
18
- expect(await axe(slot)).toHaveNoViolations()
19
- }
20
- export { slotsTest }