@datametria/vue-components 2.3.0 → 2.4.0
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/README.md +625 -594
- package/dist/index.es.js +1962 -1887
- package/dist/index.umd.js +6 -6
- package/dist/src/components/DatametriaForm.vue.d.ts +1 -1
- package/dist/src/components/DatametriaInput.vue.d.ts +9 -1
- package/dist/src/components/DatametriaSelect.vue.d.ts +10 -1
- package/dist/vue-components.css +1 -1
- package/package.json +103 -105
- package/src/components/DatametriaAlert.vue +151 -133
- package/src/components/DatametriaAutocomplete.vue +250 -229
- package/src/components/DatametriaAvatar.vue +256 -238
- package/src/components/DatametriaBadge.vue +101 -96
- package/src/components/DatametriaBreadcrumb.vue +132 -128
- package/src/components/DatametriaButton.vue +191 -173
- package/src/components/DatametriaCard.vue +84 -66
- package/src/components/DatametriaCheckbox.vue +197 -193
- package/src/components/DatametriaCheckboxGroup.vue +56 -38
- package/src/components/DatametriaChip.vue +159 -141
- package/src/components/DatametriaContainer.vue +70 -52
- package/src/components/DatametriaDataTable.vue +318 -300
- package/src/components/DatametriaDatePicker.vue +396 -378
- package/src/components/DatametriaDialog.vue +297 -293
- package/src/components/DatametriaDivider.vue +105 -98
- package/src/components/DatametriaDropdown.vue +356 -350
- package/src/components/DatametriaEmpty.vue +155 -151
- package/src/components/DatametriaFileUpload.vue +413 -395
- package/src/components/DatametriaFloatingBar.vue +144 -126
- package/src/components/DatametriaForm.vue +174 -156
- package/src/components/DatametriaFormItem.vue +183 -179
- package/src/components/DatametriaGrid.vue +55 -37
- package/src/components/DatametriaInput.vue +314 -263
- package/src/components/DatametriaMenu.vue +618 -600
- package/src/components/DatametriaModal.vue +147 -129
- package/src/components/DatametriaNavbar.vue +277 -223
- package/src/components/DatametriaPagination.vue +375 -371
- package/src/components/DatametriaPasswordInput.vue +444 -426
- package/src/components/DatametriaPopconfirm.vue +240 -234
- package/src/components/DatametriaProgress.vue +228 -224
- package/src/components/DatametriaRadio.vue +151 -147
- package/src/components/DatametriaRadioGroup.vue +55 -37
- package/src/components/DatametriaResult.vue +135 -131
- package/src/components/DatametriaSelect.vue +311 -211
- package/src/components/DatametriaSidebar.vue +294 -222
- package/src/components/DatametriaSkeleton.vue +257 -234
- package/src/components/DatametriaSlider.vue +409 -391
- package/src/components/DatametriaSortableTable.vue +820 -802
- package/src/components/DatametriaSpinner.vue +114 -110
- package/src/components/DatametriaSteps.vue +318 -312
- package/src/components/DatametriaSwitch.vue +146 -142
- package/src/components/DatametriaTabPane.vue +94 -76
- package/src/components/DatametriaTable.vue +118 -100
- package/src/components/DatametriaTabs.vue +315 -297
- package/src/components/DatametriaTextarea.vue +213 -195
- package/src/components/DatametriaTimePicker.vue +317 -299
- package/src/components/DatametriaToast.vue +176 -176
- package/src/components/DatametriaTooltip.vue +421 -400
- package/src/components/DatametriaTree.vue +126 -122
- package/src/components/DatametriaTreeNode.vue +176 -172
- package/src/components/DatametriaUpload.vue +379 -361
- package/src/components/__tests__/DatametriaAlert.test.js +35 -35
- package/src/components/__tests__/DatametriaAlert.test.ts +190 -190
- package/src/components/__tests__/DatametriaAvatar.test.ts +151 -151
- package/src/components/__tests__/DatametriaBadge.test.js +29 -29
- package/src/components/__tests__/DatametriaBadge.test.ts +167 -167
- package/src/components/__tests__/DatametriaBreadcrumb.test.ts +187 -0
- package/src/components/__tests__/DatametriaButton.test.js +30 -30
- package/src/components/__tests__/DatametriaButton.test.ts +283 -283
- package/src/components/__tests__/DatametriaCard.test.ts +201 -201
- package/src/components/__tests__/DatametriaCheckbox.test.ts +204 -0
- package/src/components/__tests__/DatametriaChip.test.js +38 -38
- package/src/components/__tests__/DatametriaContainer.test.ts +52 -52
- package/src/components/__tests__/DatametriaDialog.test.ts +338 -0
- package/src/components/__tests__/DatametriaDivider.test.ts +54 -54
- package/src/components/__tests__/DatametriaDropdown.test.ts +357 -0
- package/src/components/__tests__/DatametriaEmpty.test.ts +261 -0
- package/src/components/__tests__/DatametriaFileUpload.test.ts +290 -290
- package/src/components/__tests__/DatametriaFloatingBar.test.ts +137 -137
- package/src/components/__tests__/DatametriaForm.test.ts +96 -0
- package/src/components/__tests__/DatametriaFormItem.test.ts +58 -0
- package/src/components/__tests__/DatametriaGrid.test.ts +31 -31
- package/src/components/__tests__/DatametriaInput.test.ts +72 -72
- package/src/components/__tests__/DatametriaMenu.test.ts +366 -366
- package/src/components/__tests__/DatametriaModal.test.ts +86 -86
- package/src/components/__tests__/DatametriaNavbar.test.js +48 -48
- package/src/components/__tests__/DatametriaNavbar.test.ts +203 -203
- package/src/components/__tests__/DatametriaPasswordInput.test.js +305 -305
- package/src/components/__tests__/DatametriaRadio.test.ts +195 -0
- package/src/components/__tests__/DatametriaSelect.test.ts +77 -77
- package/src/components/__tests__/DatametriaSidebar.test.ts +169 -169
- package/src/components/__tests__/DatametriaSlider.test.ts +261 -261
- package/src/components/__tests__/DatametriaSortableTable.test.js +168 -168
- package/src/components/__tests__/DatametriaSpinner.test.ts +156 -156
- package/src/components/__tests__/DatametriaSteps.test.ts +211 -0
- package/src/components/__tests__/DatametriaSwitch.test.ts +129 -0
- package/src/components/__tests__/DatametriaTabPane.test.ts +205 -0
- package/src/components/__tests__/DatametriaTable.test.ts +97 -97
- package/src/components/__tests__/DatametriaTabs.test.ts +232 -232
- package/src/components/__tests__/DatametriaToast.test.js +48 -48
- package/src/components/__tests__/DatametriaToast.test.ts +99 -99
- package/src/components/__tests__/DatametriaTree.test.ts +376 -0
- package/src/components/__tests__/index.test.ts +48 -0
- package/src/composables/useAccessibilityScale.ts +94 -94
- package/src/composables/useBreakpoints.ts +82 -82
- package/src/composables/useHapticFeedback.ts +439 -439
- package/src/composables/useRipple.ts +218 -218
- package/src/composables/useTheme.ts +5 -1
- package/src/index.ts +84 -84
- package/src/stories/Variants.stories.js +95 -95
- package/src/styles/design-tokens.css +623 -623
- package/src/theme/ThemeProvider.vue +96 -96
- package/src/theme/__tests__/ThemeProvider.test.ts +208 -208
- package/src/theme/__tests__/constants.test.ts +31 -31
- package/src/theme/__tests__/presets.test.ts +166 -166
- package/src/theme/__tests__/tokens.test.ts +155 -155
- package/src/theme/__tests__/types.test.ts +153 -153
- package/src/theme/__tests__/useTheme.test.ts +146 -146
- package/src/theme/constants.ts +14 -14
- package/src/theme/index.ts +12 -12
- package/src/theme/presets/datametria.ts +94 -94
- package/src/theme/presets/default.ts +94 -94
- package/src/theme/presets/index.ts +8 -8
- package/src/theme/tokens/colors.ts +28 -28
- package/src/theme/tokens/index.ts +47 -47
- package/src/theme/tokens/spacing.ts +21 -21
- package/src/theme/tokens/typography.ts +35 -35
- package/src/theme/types.ts +111 -111
- package/src/theme/useTheme.ts +28 -28
- package/src/types/index.ts +55 -55
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import DatametriaRadio from '../DatametriaRadio.vue'
|
|
4
|
+
import DatametriaRadioGroup from '../DatametriaRadioGroup.vue'
|
|
5
|
+
|
|
6
|
+
describe('DatametriaRadio', () => {
|
|
7
|
+
it('renders correctly', () => {
|
|
8
|
+
const wrapper = mount(DatametriaRadio, {
|
|
9
|
+
props: { label: 'Test Radio', modelValue: 'test' }
|
|
10
|
+
})
|
|
11
|
+
expect(wrapper.find('.datametria-radio').exists()).toBe(true)
|
|
12
|
+
expect(wrapper.text()).toContain('Test Radio')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('renders with slot content', () => {
|
|
16
|
+
const wrapper = mount(DatametriaRadio, {
|
|
17
|
+
props: { modelValue: 'test' },
|
|
18
|
+
slots: { default: 'Slot Content' }
|
|
19
|
+
})
|
|
20
|
+
expect(wrapper.text()).toContain('Slot Content')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('emits update:modelValue when clicked', async () => {
|
|
24
|
+
const wrapper = mount(DatametriaRadio, {
|
|
25
|
+
props: { modelValue: 'option1' }
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const input = wrapper.find('input[type="radio"]')
|
|
29
|
+
await input.trigger('change')
|
|
30
|
+
|
|
31
|
+
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual(['option1'])
|
|
32
|
+
expect(wrapper.emitted('change')?.[0]).toEqual(['option1'])
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('handles disabled state', async () => {
|
|
36
|
+
const wrapper = mount(DatametriaRadio, {
|
|
37
|
+
props: { disabled: true, modelValue: 'test' }
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
expect(wrapper.find('.datametria-radio').classes()).toContain('is-disabled')
|
|
41
|
+
expect(wrapper.find('input').attributes('disabled')).toBeDefined()
|
|
42
|
+
|
|
43
|
+
const input = wrapper.find('input')
|
|
44
|
+
await input.trigger('change')
|
|
45
|
+
expect(wrapper.emitted('update:modelValue')).toBeUndefined()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('exposes inputRef', () => {
|
|
49
|
+
const wrapper = mount(DatametriaRadio, {
|
|
50
|
+
props: { modelValue: 'test' }
|
|
51
|
+
})
|
|
52
|
+
expect(wrapper.vm.inputRef).toBeDefined()
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('renders without label when not provided', () => {
|
|
56
|
+
const wrapper = mount(DatametriaRadio, {
|
|
57
|
+
props: { modelValue: 'test' }
|
|
58
|
+
})
|
|
59
|
+
expect(wrapper.find('.datametria-radio__label').exists()).toBe(false)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('works within radio group', async () => {
|
|
63
|
+
const wrapper = mount(DatametriaRadioGroup, {
|
|
64
|
+
props: {
|
|
65
|
+
modelValue: 'option1',
|
|
66
|
+
'onUpdate:modelValue': (value: string) => wrapper.setProps({ modelValue: value })
|
|
67
|
+
},
|
|
68
|
+
slots: {
|
|
69
|
+
default: `
|
|
70
|
+
<DatametriaRadio modelValue="option1" label="Option 1" />
|
|
71
|
+
<DatametriaRadio modelValue="option2" label="Option 2" />
|
|
72
|
+
`
|
|
73
|
+
},
|
|
74
|
+
global: {
|
|
75
|
+
components: { DatametriaRadio }
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const radios = wrapper.findAllComponents(DatametriaRadio)
|
|
80
|
+
expect(radios).toHaveLength(2)
|
|
81
|
+
expect(radios[0].classes()).toContain('is-checked')
|
|
82
|
+
expect(radios[1].classes()).not.toContain('is-checked')
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('updates group value when radio is selected', async () => {
|
|
86
|
+
const wrapper = mount(DatametriaRadioGroup, {
|
|
87
|
+
props: {
|
|
88
|
+
modelValue: 'option1',
|
|
89
|
+
'onUpdate:modelValue': (value: string) => wrapper.setProps({ modelValue: value })
|
|
90
|
+
},
|
|
91
|
+
slots: {
|
|
92
|
+
default: `
|
|
93
|
+
<DatametriaRadio modelValue="option1" label="Option 1" />
|
|
94
|
+
<DatametriaRadio modelValue="option2" label="Option 2" />
|
|
95
|
+
`
|
|
96
|
+
},
|
|
97
|
+
global: {
|
|
98
|
+
components: { DatametriaRadio }
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const radios = wrapper.findAllComponents(DatametriaRadio)
|
|
103
|
+
const input = radios[1].find('input')
|
|
104
|
+
await input.trigger('change')
|
|
105
|
+
|
|
106
|
+
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual(['option2'])
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('only one radio can be selected in group', async () => {
|
|
110
|
+
const wrapper = mount(DatametriaRadioGroup, {
|
|
111
|
+
props: {
|
|
112
|
+
modelValue: 'option1',
|
|
113
|
+
'onUpdate:modelValue': (value: string) => wrapper.setProps({ modelValue: value })
|
|
114
|
+
},
|
|
115
|
+
slots: {
|
|
116
|
+
default: `
|
|
117
|
+
<DatametriaRadio modelValue="option1" label="Option 1" />
|
|
118
|
+
<DatametriaRadio modelValue="option2" label="Option 2" />
|
|
119
|
+
<DatametriaRadio modelValue="option3" label="Option 3" />
|
|
120
|
+
`
|
|
121
|
+
},
|
|
122
|
+
global: {
|
|
123
|
+
components: { DatametriaRadio }
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
await wrapper.setProps({ modelValue: 'option2' })
|
|
128
|
+
await wrapper.vm.$nextTick()
|
|
129
|
+
|
|
130
|
+
const radios = wrapper.findAllComponents(DatametriaRadio)
|
|
131
|
+
expect(radios[0].classes()).not.toContain('is-checked')
|
|
132
|
+
expect(radios[1].classes()).toContain('is-checked')
|
|
133
|
+
expect(radios[2].classes()).not.toContain('is-checked')
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
it('emits change event', async () => {
|
|
137
|
+
const wrapper = mount(DatametriaRadio, {
|
|
138
|
+
props: { modelValue: 'test' }
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
const input = wrapper.find('input')
|
|
142
|
+
await input.trigger('change')
|
|
143
|
+
|
|
144
|
+
expect(wrapper.emitted('change')).toBeTruthy()
|
|
145
|
+
expect(wrapper.emitted('change')?.[0]).toEqual(['test'])
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
it('applies checked class when selected in group', async () => {
|
|
149
|
+
const wrapper = mount(DatametriaRadioGroup, {
|
|
150
|
+
props: { modelValue: 'option1' },
|
|
151
|
+
slots: {
|
|
152
|
+
default: `<DatametriaRadio modelValue="option1" label="Option 1" />`
|
|
153
|
+
},
|
|
154
|
+
global: {
|
|
155
|
+
components: { DatametriaRadio }
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
const radio = wrapper.findComponent(DatametriaRadio)
|
|
160
|
+
expect(radio.classes()).toContain('is-checked')
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it('supports string values', async () => {
|
|
164
|
+
const wrapper = mount(DatametriaRadio, {
|
|
165
|
+
props: { modelValue: 'string-value' }
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
const input = wrapper.find('input')
|
|
169
|
+
await input.trigger('change')
|
|
170
|
+
|
|
171
|
+
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual(['string-value'])
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
it('supports number values', async () => {
|
|
175
|
+
const wrapper = mount(DatametriaRadio, {
|
|
176
|
+
props: { modelValue: 123 }
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
const input = wrapper.find('input')
|
|
180
|
+
await input.trigger('change')
|
|
181
|
+
|
|
182
|
+
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([123])
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
it('supports boolean values', async () => {
|
|
186
|
+
const wrapper = mount(DatametriaRadio, {
|
|
187
|
+
props: { modelValue: true }
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
const input = wrapper.find('input')
|
|
191
|
+
await input.trigger('change')
|
|
192
|
+
|
|
193
|
+
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([true])
|
|
194
|
+
})
|
|
195
|
+
})
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { mount } from '@vue/test-utils'
|
|
3
|
-
import DatametriaSelect from '../DatametriaSelect.vue'
|
|
4
|
-
|
|
5
|
-
describe('DatametriaSelect', () => {
|
|
6
|
-
const options = [
|
|
7
|
-
{ value: '1', label: 'Option 1' },
|
|
8
|
-
{ value: '2', label: 'Option 2' },
|
|
9
|
-
{ value: '3', label: 'Option 3' }
|
|
10
|
-
]
|
|
11
|
-
|
|
12
|
-
it('renders correctly', () => {
|
|
13
|
-
const wrapper = mount(DatametriaSelect, {
|
|
14
|
-
props: { options }
|
|
15
|
-
})
|
|
16
|
-
expect(wrapper.find('.datametria-select').exists()).toBe(true)
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('renders label when provided', () => {
|
|
20
|
-
const wrapper = mount(DatametriaSelect, {
|
|
21
|
-
props: { options, label: 'Select Label' }
|
|
22
|
-
})
|
|
23
|
-
expect(wrapper.find('.datametria-select__label').text()).toContain('Select Label')
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('shows required indicator', () => {
|
|
27
|
-
const wrapper = mount(DatametriaSelect, {
|
|
28
|
-
props: { options, label: 'Test', required: true }
|
|
29
|
-
})
|
|
30
|
-
expect(wrapper.find('.datametria-select__required').exists()).toBe(true)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('renders all options', () => {
|
|
34
|
-
const wrapper = mount(DatametriaSelect, {
|
|
35
|
-
props: { options }
|
|
36
|
-
})
|
|
37
|
-
const optionElements = wrapper.findAll('option')
|
|
38
|
-
expect(optionElements.length).toBeGreaterThanOrEqual(3)
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('renders placeholder option', () => {
|
|
42
|
-
const wrapper = mount(DatametriaSelect, {
|
|
43
|
-
props: { options, placeholder: 'Choose option' }
|
|
44
|
-
})
|
|
45
|
-
const firstOption = wrapper.find('option')
|
|
46
|
-
expect(firstOption.text()).toBe('Choose option')
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('binds modelValue correctly', () => {
|
|
50
|
-
const wrapper = mount(DatametriaSelect, {
|
|
51
|
-
props: { options, modelValue: '2' }
|
|
52
|
-
})
|
|
53
|
-
expect((wrapper.find('select').element as HTMLSelectElement).value).toBe('2')
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('emits update:modelValue on change', async () => {
|
|
57
|
-
const wrapper = mount(DatametriaSelect, {
|
|
58
|
-
props: { options }
|
|
59
|
-
})
|
|
60
|
-
await wrapper.find('select').setValue('2')
|
|
61
|
-
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual(['2'])
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it('shows error message', () => {
|
|
65
|
-
const wrapper = mount(DatametriaSelect, {
|
|
66
|
-
props: { options, errorMessage: 'Error text' }
|
|
67
|
-
})
|
|
68
|
-
expect(wrapper.find('.datametria-select__error').text()).toBe('Error text')
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it('applies disabled state', () => {
|
|
72
|
-
const wrapper = mount(DatametriaSelect, {
|
|
73
|
-
props: { options, disabled: true }
|
|
74
|
-
})
|
|
75
|
-
expect(wrapper.find('select').attributes('disabled')).toBeDefined()
|
|
76
|
-
})
|
|
77
|
-
})
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import DatametriaSelect from '../DatametriaSelect.vue'
|
|
4
|
+
|
|
5
|
+
describe('DatametriaSelect', () => {
|
|
6
|
+
const options = [
|
|
7
|
+
{ value: '1', label: 'Option 1' },
|
|
8
|
+
{ value: '2', label: 'Option 2' },
|
|
9
|
+
{ value: '3', label: 'Option 3' }
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
it('renders correctly', () => {
|
|
13
|
+
const wrapper = mount(DatametriaSelect, {
|
|
14
|
+
props: { options }
|
|
15
|
+
})
|
|
16
|
+
expect(wrapper.find('.datametria-select').exists()).toBe(true)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('renders label when provided', () => {
|
|
20
|
+
const wrapper = mount(DatametriaSelect, {
|
|
21
|
+
props: { options, label: 'Select Label' }
|
|
22
|
+
})
|
|
23
|
+
expect(wrapper.find('.datametria-select__label').text()).toContain('Select Label')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('shows required indicator', () => {
|
|
27
|
+
const wrapper = mount(DatametriaSelect, {
|
|
28
|
+
props: { options, label: 'Test', required: true }
|
|
29
|
+
})
|
|
30
|
+
expect(wrapper.find('.datametria-select__required').exists()).toBe(true)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('renders all options', () => {
|
|
34
|
+
const wrapper = mount(DatametriaSelect, {
|
|
35
|
+
props: { options }
|
|
36
|
+
})
|
|
37
|
+
const optionElements = wrapper.findAll('option')
|
|
38
|
+
expect(optionElements.length).toBeGreaterThanOrEqual(3)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('renders placeholder option', () => {
|
|
42
|
+
const wrapper = mount(DatametriaSelect, {
|
|
43
|
+
props: { options, placeholder: 'Choose option' }
|
|
44
|
+
})
|
|
45
|
+
const firstOption = wrapper.find('option')
|
|
46
|
+
expect(firstOption.text()).toBe('Choose option')
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('binds modelValue correctly', () => {
|
|
50
|
+
const wrapper = mount(DatametriaSelect, {
|
|
51
|
+
props: { options, modelValue: '2' }
|
|
52
|
+
})
|
|
53
|
+
expect((wrapper.find('select').element as HTMLSelectElement).value).toBe('2')
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('emits update:modelValue on change', async () => {
|
|
57
|
+
const wrapper = mount(DatametriaSelect, {
|
|
58
|
+
props: { options }
|
|
59
|
+
})
|
|
60
|
+
await wrapper.find('select').setValue('2')
|
|
61
|
+
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual(['2'])
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('shows error message', () => {
|
|
65
|
+
const wrapper = mount(DatametriaSelect, {
|
|
66
|
+
props: { options, errorMessage: 'Error text' }
|
|
67
|
+
})
|
|
68
|
+
expect(wrapper.find('.datametria-select__error').text()).toBe('Error text')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('applies disabled state', () => {
|
|
72
|
+
const wrapper = mount(DatametriaSelect, {
|
|
73
|
+
props: { options, disabled: true }
|
|
74
|
+
})
|
|
75
|
+
expect(wrapper.find('select').attributes('disabled')).toBeDefined()
|
|
76
|
+
})
|
|
77
|
+
})
|