@datametria/vue-components 2.3.1 → 2.4.1

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 (126) hide show
  1. package/README.md +625 -594
  2. package/dist/index.es.js +1962 -1887
  3. package/dist/index.umd.js +6 -6
  4. package/dist/src/components/DatametriaForm.vue.d.ts +1 -1
  5. package/dist/src/components/DatametriaInput.vue.d.ts +9 -1
  6. package/dist/src/components/DatametriaSelect.vue.d.ts +10 -1
  7. package/dist/vue-components.css +1 -1
  8. package/package.json +103 -102
  9. package/src/components/DatametriaAlert.vue +151 -133
  10. package/src/components/DatametriaAutocomplete.vue +250 -229
  11. package/src/components/DatametriaAvatar.vue +256 -238
  12. package/src/components/DatametriaBadge.vue +101 -96
  13. package/src/components/DatametriaBreadcrumb.vue +132 -128
  14. package/src/components/DatametriaButton.vue +191 -173
  15. package/src/components/DatametriaCard.vue +84 -66
  16. package/src/components/DatametriaCheckbox.vue +197 -193
  17. package/src/components/DatametriaChip.vue +159 -141
  18. package/src/components/DatametriaContainer.vue +70 -52
  19. package/src/components/DatametriaDataTable.vue +318 -300
  20. package/src/components/DatametriaDatePicker.vue +396 -378
  21. package/src/components/DatametriaDialog.vue +297 -293
  22. package/src/components/DatametriaDivider.vue +105 -98
  23. package/src/components/DatametriaDropdown.vue +356 -350
  24. package/src/components/DatametriaEmpty.vue +155 -151
  25. package/src/components/DatametriaFileUpload.vue +413 -395
  26. package/src/components/DatametriaFloatingBar.vue +144 -126
  27. package/src/components/DatametriaForm.vue +174 -156
  28. package/src/components/DatametriaFormItem.vue +183 -179
  29. package/src/components/DatametriaGrid.vue +55 -37
  30. package/src/components/DatametriaInput.vue +314 -263
  31. package/src/components/DatametriaMenu.vue +618 -600
  32. package/src/components/DatametriaModal.vue +147 -129
  33. package/src/components/DatametriaNavbar.vue +277 -223
  34. package/src/components/DatametriaPagination.vue +375 -371
  35. package/src/components/DatametriaPasswordInput.vue +446 -426
  36. package/src/components/DatametriaPopconfirm.vue +240 -234
  37. package/src/components/DatametriaProgress.vue +228 -224
  38. package/src/components/DatametriaRadio.vue +151 -147
  39. package/src/components/DatametriaResult.vue +135 -131
  40. package/src/components/DatametriaSelect.vue +311 -211
  41. package/src/components/DatametriaSidebar.vue +294 -222
  42. package/src/components/DatametriaSkeleton.vue +257 -234
  43. package/src/components/DatametriaSlider.vue +409 -391
  44. package/src/components/DatametriaSortableTable.vue +826 -802
  45. package/src/components/DatametriaSpinner.vue +114 -110
  46. package/src/components/DatametriaSteps.vue +318 -312
  47. package/src/components/DatametriaSwitch.vue +146 -142
  48. package/src/components/DatametriaTabPane.vue +94 -76
  49. package/src/components/DatametriaTable.vue +118 -100
  50. package/src/components/DatametriaTabs.vue +315 -297
  51. package/src/components/DatametriaTextarea.vue +213 -195
  52. package/src/components/DatametriaTimePicker.vue +317 -299
  53. package/src/components/DatametriaToast.vue +176 -176
  54. package/src/components/DatametriaTooltip.vue +421 -400
  55. package/src/components/DatametriaTree.vue +126 -122
  56. package/src/components/DatametriaTreeNode.vue +176 -172
  57. package/src/components/DatametriaUpload.vue +379 -361
  58. package/src/components/__tests__/DatametriaAlert.test.js +35 -35
  59. package/src/components/__tests__/DatametriaAlert.test.ts +190 -190
  60. package/src/components/__tests__/DatametriaAvatar.test.ts +151 -151
  61. package/src/components/__tests__/DatametriaBadge.test.js +29 -29
  62. package/src/components/__tests__/DatametriaBadge.test.ts +167 -167
  63. package/src/components/__tests__/DatametriaBreadcrumb.test.ts +187 -0
  64. package/src/components/__tests__/DatametriaButton.test.js +30 -30
  65. package/src/components/__tests__/DatametriaButton.test.ts +283 -283
  66. package/src/components/__tests__/DatametriaCard.test.ts +201 -201
  67. package/src/components/__tests__/DatametriaCheckbox.test.ts +204 -0
  68. package/src/components/__tests__/DatametriaChip.test.js +38 -38
  69. package/src/components/__tests__/DatametriaContainer.test.ts +52 -52
  70. package/src/components/__tests__/DatametriaDialog.test.ts +338 -0
  71. package/src/components/__tests__/DatametriaDivider.test.ts +54 -54
  72. package/src/components/__tests__/DatametriaDropdown.test.ts +357 -0
  73. package/src/components/__tests__/DatametriaEmpty.test.ts +261 -0
  74. package/src/components/__tests__/DatametriaFileUpload.test.ts +290 -290
  75. package/src/components/__tests__/DatametriaFloatingBar.test.ts +137 -137
  76. package/src/components/__tests__/DatametriaForm.test.ts +96 -0
  77. package/src/components/__tests__/DatametriaFormItem.test.ts +58 -0
  78. package/src/components/__tests__/DatametriaGrid.test.ts +31 -31
  79. package/src/components/__tests__/DatametriaInput.test.ts +72 -72
  80. package/src/components/__tests__/DatametriaMenu.test.ts +366 -366
  81. package/src/components/__tests__/DatametriaModal.test.ts +86 -86
  82. package/src/components/__tests__/DatametriaNavbar.test.js +48 -48
  83. package/src/components/__tests__/DatametriaNavbar.test.ts +203 -203
  84. package/src/components/__tests__/DatametriaPasswordInput.test.js +305 -305
  85. package/src/components/__tests__/DatametriaRadio.test.ts +195 -0
  86. package/src/components/__tests__/DatametriaSelect.test.ts +77 -77
  87. package/src/components/__tests__/DatametriaSidebar.test.ts +169 -169
  88. package/src/components/__tests__/DatametriaSlider.test.ts +261 -261
  89. package/src/components/__tests__/DatametriaSortableTable.test.js +168 -168
  90. package/src/components/__tests__/DatametriaSpinner.test.ts +156 -156
  91. package/src/components/__tests__/DatametriaSteps.test.ts +211 -0
  92. package/src/components/__tests__/DatametriaSwitch.test.ts +129 -0
  93. package/src/components/__tests__/DatametriaTabPane.test.ts +205 -0
  94. package/src/components/__tests__/DatametriaTable.test.ts +97 -97
  95. package/src/components/__tests__/DatametriaTabs.test.ts +232 -232
  96. package/src/components/__tests__/DatametriaToast.test.js +48 -48
  97. package/src/components/__tests__/DatametriaToast.test.ts +99 -99
  98. package/src/components/__tests__/DatametriaTree.test.ts +376 -0
  99. package/src/components/__tests__/index.test.ts +48 -0
  100. package/src/composables/useAccessibilityScale.ts +94 -94
  101. package/src/composables/useBreakpoints.ts +82 -82
  102. package/src/composables/useHapticFeedback.ts +439 -439
  103. package/src/composables/useRipple.ts +218 -218
  104. package/src/composables/useTheme.ts +5 -1
  105. package/src/index.ts +84 -84
  106. package/src/stories/Variants.stories.js +95 -95
  107. package/src/styles/design-tokens.css +623 -623
  108. package/src/theme/ThemeProvider.vue +96 -96
  109. package/src/theme/__tests__/ThemeProvider.test.ts +208 -208
  110. package/src/theme/__tests__/constants.test.ts +31 -31
  111. package/src/theme/__tests__/presets.test.ts +166 -166
  112. package/src/theme/__tests__/tokens.test.ts +155 -155
  113. package/src/theme/__tests__/types.test.ts +153 -153
  114. package/src/theme/__tests__/useTheme.test.ts +146 -146
  115. package/src/theme/constants.ts +14 -14
  116. package/src/theme/index.ts +12 -12
  117. package/src/theme/presets/datametria.ts +94 -94
  118. package/src/theme/presets/default.ts +94 -94
  119. package/src/theme/presets/index.ts +8 -8
  120. package/src/theme/tokens/colors.ts +28 -28
  121. package/src/theme/tokens/index.ts +47 -47
  122. package/src/theme/tokens/spacing.ts +21 -21
  123. package/src/theme/tokens/typography.ts +35 -35
  124. package/src/theme/types.ts +111 -111
  125. package/src/theme/useTheme.ts +28 -28
  126. package/src/types/index.ts +55 -55
@@ -1,137 +1,137 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { mount } from '@vue/test-utils'
3
- import DatametriaFloatingBar from '../DatametriaFloatingBar.vue'
4
-
5
- describe('DatametriaFloatingBar', () => {
6
- it('renders correctly', () => {
7
- const wrapper = mount(DatametriaFloatingBar)
8
- expect(wrapper.find('.dm-floating-bar').exists()).toBe(true)
9
- })
10
-
11
- it('applies position classes', () => {
12
- const positions = ['top', 'bottom', 'left', 'right'] as const
13
- positions.forEach(position => {
14
- const wrapper = mount(DatametriaFloatingBar, { props: { position } })
15
- expect(wrapper.find(`.dm-floating-bar--${position}`).exists()).toBe(true)
16
- })
17
- })
18
-
19
- it('applies variant classes', () => {
20
- const variants = ['light', 'dark', 'primary'] as const
21
- variants.forEach(variant => {
22
- const wrapper = mount(DatametriaFloatingBar, { props: { variant } })
23
- expect(wrapper.find(`.dm-floating-bar--${variant}`).exists()).toBe(true)
24
- })
25
- })
26
-
27
- it('applies shadow class when shadow is true', () => {
28
- const wrapper = mount(DatametriaFloatingBar, { props: { shadow: true } })
29
- expect(wrapper.find('.dm-floating-bar--shadow').exists()).toBe(true)
30
- })
31
-
32
- it('does not apply shadow class when shadow is false', () => {
33
- const wrapper = mount(DatametriaFloatingBar, { props: { shadow: false } })
34
- expect(wrapper.find('.dm-floating-bar--shadow').exists()).toBe(false)
35
- })
36
-
37
- it('applies rounded class when rounded is true', () => {
38
- const wrapper = mount(DatametriaFloatingBar, { props: { rounded: true } })
39
- expect(wrapper.find('.dm-floating-bar--rounded').exists()).toBe(true)
40
- })
41
-
42
- it('does not apply rounded class when rounded is false', () => {
43
- const wrapper = mount(DatametriaFloatingBar, { props: { rounded: false } })
44
- expect(wrapper.find('.dm-floating-bar--rounded').exists()).toBe(false)
45
- })
46
-
47
- it('renders slot content', () => {
48
- const wrapper = mount(DatametriaFloatingBar, {
49
- slots: { default: '<button class="test-button">Action</button>' }
50
- })
51
- expect(wrapper.find('.test-button').exists()).toBe(true)
52
- expect(wrapper.text()).toContain('Action')
53
- })
54
-
55
- it('applies correct position style for top', () => {
56
- const wrapper = mount(DatametriaFloatingBar, {
57
- props: { position: 'top', offset: '20px' }
58
- })
59
- const style = wrapper.find('.dm-floating-bar').attributes('style')
60
- expect(style).toContain('top: 20px')
61
- })
62
-
63
- it('applies correct position style for bottom', () => {
64
- const wrapper = mount(DatametriaFloatingBar, {
65
- props: { position: 'bottom', offset: '24px' }
66
- })
67
- const style = wrapper.find('.dm-floating-bar').attributes('style')
68
- expect(style).toContain('bottom: 24px')
69
- })
70
-
71
- it('applies correct position style for left', () => {
72
- const wrapper = mount(DatametriaFloatingBar, {
73
- props: { position: 'left', offset: '32px' }
74
- })
75
- const style = wrapper.find('.dm-floating-bar').attributes('style')
76
- expect(style).toContain('left: 32px')
77
- })
78
-
79
- it('applies correct position style for right', () => {
80
- const wrapper = mount(DatametriaFloatingBar, {
81
- props: { position: 'right', offset: '40px' }
82
- })
83
- const style = wrapper.find('.dm-floating-bar').attributes('style')
84
- expect(style).toContain('right: 40px')
85
- })
86
-
87
- it('uses default offset when not provided', () => {
88
- const wrapper = mount(DatametriaFloatingBar, { props: { position: 'bottom' } })
89
- const style = wrapper.find('.dm-floating-bar').attributes('style')
90
- expect(style).toContain('bottom: 16px')
91
- })
92
-
93
- it('has correct aria attributes', () => {
94
- const wrapper = mount(DatametriaFloatingBar, {
95
- props: { ariaLabel: 'Floating toolbar' }
96
- })
97
- const bar = wrapper.find('.dm-floating-bar')
98
- expect(bar.attributes('role')).toBe('toolbar')
99
- expect(bar.attributes('aria-label')).toBe('Floating toolbar')
100
- })
101
-
102
- it('renders content wrapper', () => {
103
- const wrapper = mount(DatametriaFloatingBar)
104
- expect(wrapper.find('.dm-floating-bar__content').exists()).toBe(true)
105
- })
106
-
107
- it('applies all classes correctly', () => {
108
- const wrapper = mount(DatametriaFloatingBar, {
109
- props: {
110
- position: 'top',
111
- variant: 'primary',
112
- shadow: true,
113
- rounded: true
114
- }
115
- })
116
- const bar = wrapper.find('.dm-floating-bar')
117
- expect(bar.classes()).toContain('dm-floating-bar--top')
118
- expect(bar.classes()).toContain('dm-floating-bar--primary')
119
- expect(bar.classes()).toContain('dm-floating-bar--shadow')
120
- expect(bar.classes()).toContain('dm-floating-bar--rounded')
121
- })
122
-
123
- it('renders multiple action buttons', () => {
124
- const wrapper = mount(DatametriaFloatingBar, {
125
- slots: {
126
- default: `
127
- <button class="btn-1">Action 1</button>
128
- <button class="btn-2">Action 2</button>
129
- <button class="btn-3">Action 3</button>
130
- `
131
- }
132
- })
133
- expect(wrapper.find('.btn-1').exists()).toBe(true)
134
- expect(wrapper.find('.btn-2').exists()).toBe(true)
135
- expect(wrapper.find('.btn-3').exists()).toBe(true)
136
- })
137
- })
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import DatametriaFloatingBar from '../DatametriaFloatingBar.vue'
4
+
5
+ describe('DatametriaFloatingBar', () => {
6
+ it('renders correctly', () => {
7
+ const wrapper = mount(DatametriaFloatingBar)
8
+ expect(wrapper.find('.dm-floating-bar').exists()).toBe(true)
9
+ })
10
+
11
+ it('applies position classes', () => {
12
+ const positions = ['top', 'bottom', 'left', 'right'] as const
13
+ positions.forEach(position => {
14
+ const wrapper = mount(DatametriaFloatingBar, { props: { position } })
15
+ expect(wrapper.find(`.dm-floating-bar--${position}`).exists()).toBe(true)
16
+ })
17
+ })
18
+
19
+ it('applies variant classes', () => {
20
+ const variants = ['light', 'dark', 'primary'] as const
21
+ variants.forEach(variant => {
22
+ const wrapper = mount(DatametriaFloatingBar, { props: { variant } })
23
+ expect(wrapper.find(`.dm-floating-bar--${variant}`).exists()).toBe(true)
24
+ })
25
+ })
26
+
27
+ it('applies shadow class when shadow is true', () => {
28
+ const wrapper = mount(DatametriaFloatingBar, { props: { shadow: true } })
29
+ expect(wrapper.find('.dm-floating-bar--shadow').exists()).toBe(true)
30
+ })
31
+
32
+ it('does not apply shadow class when shadow is false', () => {
33
+ const wrapper = mount(DatametriaFloatingBar, { props: { shadow: false } })
34
+ expect(wrapper.find('.dm-floating-bar--shadow').exists()).toBe(false)
35
+ })
36
+
37
+ it('applies rounded class when rounded is true', () => {
38
+ const wrapper = mount(DatametriaFloatingBar, { props: { rounded: true } })
39
+ expect(wrapper.find('.dm-floating-bar--rounded').exists()).toBe(true)
40
+ })
41
+
42
+ it('does not apply rounded class when rounded is false', () => {
43
+ const wrapper = mount(DatametriaFloatingBar, { props: { rounded: false } })
44
+ expect(wrapper.find('.dm-floating-bar--rounded').exists()).toBe(false)
45
+ })
46
+
47
+ it('renders slot content', () => {
48
+ const wrapper = mount(DatametriaFloatingBar, {
49
+ slots: { default: '<button class="test-button">Action</button>' }
50
+ })
51
+ expect(wrapper.find('.test-button').exists()).toBe(true)
52
+ expect(wrapper.text()).toContain('Action')
53
+ })
54
+
55
+ it('applies correct position style for top', () => {
56
+ const wrapper = mount(DatametriaFloatingBar, {
57
+ props: { position: 'top', offset: '20px' }
58
+ })
59
+ const style = wrapper.find('.dm-floating-bar').attributes('style')
60
+ expect(style).toContain('top: 20px')
61
+ })
62
+
63
+ it('applies correct position style for bottom', () => {
64
+ const wrapper = mount(DatametriaFloatingBar, {
65
+ props: { position: 'bottom', offset: '24px' }
66
+ })
67
+ const style = wrapper.find('.dm-floating-bar').attributes('style')
68
+ expect(style).toContain('bottom: 24px')
69
+ })
70
+
71
+ it('applies correct position style for left', () => {
72
+ const wrapper = mount(DatametriaFloatingBar, {
73
+ props: { position: 'left', offset: '32px' }
74
+ })
75
+ const style = wrapper.find('.dm-floating-bar').attributes('style')
76
+ expect(style).toContain('left: 32px')
77
+ })
78
+
79
+ it('applies correct position style for right', () => {
80
+ const wrapper = mount(DatametriaFloatingBar, {
81
+ props: { position: 'right', offset: '40px' }
82
+ })
83
+ const style = wrapper.find('.dm-floating-bar').attributes('style')
84
+ expect(style).toContain('right: 40px')
85
+ })
86
+
87
+ it('uses default offset when not provided', () => {
88
+ const wrapper = mount(DatametriaFloatingBar, { props: { position: 'bottom' } })
89
+ const style = wrapper.find('.dm-floating-bar').attributes('style')
90
+ expect(style).toContain('bottom: 16px')
91
+ })
92
+
93
+ it('has correct aria attributes', () => {
94
+ const wrapper = mount(DatametriaFloatingBar, {
95
+ props: { ariaLabel: 'Floating toolbar' }
96
+ })
97
+ const bar = wrapper.find('.dm-floating-bar')
98
+ expect(bar.attributes('role')).toBe('toolbar')
99
+ expect(bar.attributes('aria-label')).toBe('Floating toolbar')
100
+ })
101
+
102
+ it('renders content wrapper', () => {
103
+ const wrapper = mount(DatametriaFloatingBar)
104
+ expect(wrapper.find('.dm-floating-bar__content').exists()).toBe(true)
105
+ })
106
+
107
+ it('applies all classes correctly', () => {
108
+ const wrapper = mount(DatametriaFloatingBar, {
109
+ props: {
110
+ position: 'top',
111
+ variant: 'primary',
112
+ shadow: true,
113
+ rounded: true
114
+ }
115
+ })
116
+ const bar = wrapper.find('.dm-floating-bar')
117
+ expect(bar.classes()).toContain('dm-floating-bar--top')
118
+ expect(bar.classes()).toContain('dm-floating-bar--primary')
119
+ expect(bar.classes()).toContain('dm-floating-bar--shadow')
120
+ expect(bar.classes()).toContain('dm-floating-bar--rounded')
121
+ })
122
+
123
+ it('renders multiple action buttons', () => {
124
+ const wrapper = mount(DatametriaFloatingBar, {
125
+ slots: {
126
+ default: `
127
+ <button class="btn-1">Action 1</button>
128
+ <button class="btn-2">Action 2</button>
129
+ <button class="btn-3">Action 3</button>
130
+ `
131
+ }
132
+ })
133
+ expect(wrapper.find('.btn-1').exists()).toBe(true)
134
+ expect(wrapper.find('.btn-2').exists()).toBe(true)
135
+ expect(wrapper.find('.btn-3').exists()).toBe(true)
136
+ })
137
+ })
@@ -0,0 +1,96 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import DatametriaForm from '../DatametriaForm.vue'
4
+
5
+ describe('DatametriaForm', () => {
6
+ it('renders correctly', () => {
7
+ const wrapper = mount(DatametriaForm)
8
+ expect(wrapper.find('.datametria-form').exists()).toBe(true)
9
+ })
10
+
11
+ it('applies inline class', () => {
12
+ const wrapper = mount(DatametriaForm, {
13
+ props: { inline: true }
14
+ })
15
+ expect(wrapper.find('.datametria-form--inline').exists()).toBe(true)
16
+ })
17
+
18
+ it('applies label position class', () => {
19
+ const wrapper = mount(DatametriaForm, {
20
+ props: { labelPosition: 'left' }
21
+ })
22
+ expect(wrapper.find('.datametria-form--label-left').exists()).toBe(true)
23
+ })
24
+
25
+ it('validates form returns true when no fields', async () => {
26
+ const wrapper = mount(DatametriaForm)
27
+ const valid = await wrapper.vm.validate()
28
+ expect(valid).toBe(true)
29
+ })
30
+
31
+ it('validates single field returns true when field not found', async () => {
32
+ const wrapper = mount(DatametriaForm)
33
+ const valid = await wrapper.vm.validateField('nonexistent')
34
+ expect(valid).toBe(true)
35
+ })
36
+
37
+ it('resets all fields', () => {
38
+ const wrapper = mount(DatametriaForm)
39
+ wrapper.vm.resetFields()
40
+ expect(wrapper.vm.errors).toEqual({})
41
+ })
42
+
43
+ it('clears validation', () => {
44
+ const wrapper = mount(DatametriaForm)
45
+ wrapper.vm.clearValidate()
46
+ expect(wrapper.vm.errors).toEqual({})
47
+ })
48
+
49
+ it('clears validation for specific field', () => {
50
+ const wrapper = mount(DatametriaForm)
51
+ wrapper.vm.clearValidate('name')
52
+ expect(wrapper.vm.errors).toEqual({})
53
+ })
54
+
55
+ it('clears validation for array of fields', () => {
56
+ const wrapper = mount(DatametriaForm)
57
+ wrapper.vm.clearValidate(['name', 'email'])
58
+ expect(wrapper.vm.errors).toEqual({})
59
+ })
60
+
61
+ it('emits validate event', async () => {
62
+ const wrapper = mount(DatametriaForm)
63
+ await wrapper.vm.validate()
64
+ expect(wrapper.emitted('validate')).toBeTruthy()
65
+ })
66
+
67
+ it('emits submit event on form submit', async () => {
68
+ const model = { name: 'Test' }
69
+ const wrapper = mount(DatametriaForm, {
70
+ props: { model }
71
+ })
72
+ await wrapper.find('form').trigger('submit')
73
+ expect(wrapper.emitted('submit')).toBeTruthy()
74
+ expect(wrapper.emitted('submit')?.[0]).toEqual([model])
75
+ })
76
+
77
+ it('exposes validate method', () => {
78
+ const wrapper = mount(DatametriaForm)
79
+ expect(wrapper.vm.validate).toBeDefined()
80
+ })
81
+
82
+ it('exposes validateField method', () => {
83
+ const wrapper = mount(DatametriaForm)
84
+ expect(wrapper.vm.validateField).toBeDefined()
85
+ })
86
+
87
+ it('exposes resetFields method', () => {
88
+ const wrapper = mount(DatametriaForm)
89
+ expect(wrapper.vm.resetFields).toBeDefined()
90
+ })
91
+
92
+ it('exposes clearValidate method', () => {
93
+ const wrapper = mount(DatametriaForm)
94
+ expect(wrapper.vm.clearValidate).toBeDefined()
95
+ })
96
+ })
@@ -0,0 +1,58 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import DatametriaFormItem from '../DatametriaFormItem.vue'
4
+
5
+ describe('DatametriaFormItem', () => {
6
+ it('renders correctly', () => {
7
+ const wrapper = mount(DatametriaFormItem, {
8
+ props: { label: 'Test Label' }
9
+ })
10
+ expect(wrapper.find('.datametria-form-item').exists()).toBe(true)
11
+ expect(wrapper.text()).toContain('Test Label')
12
+ })
13
+
14
+ it('renders without label', () => {
15
+ const wrapper = mount(DatametriaFormItem)
16
+ expect(wrapper.find('.datametria-form-item__label').exists()).toBe(false)
17
+ })
18
+
19
+ it('shows required indicator', () => {
20
+ const wrapper = mount(DatametriaFormItem, {
21
+ props: { label: 'Name', required: true }
22
+ })
23
+ expect(wrapper.find('.is-required').exists()).toBe(true)
24
+ })
25
+
26
+ it('validates field returns true when no rules', async () => {
27
+ const wrapper = mount(DatametriaFormItem)
28
+ const valid = await wrapper.vm.validate()
29
+ expect(valid).toBe(true)
30
+ })
31
+
32
+ it('resets field clears error', () => {
33
+ const wrapper = mount(DatametriaFormItem)
34
+ wrapper.vm.reset()
35
+ expect(wrapper.vm.errorMessage).toBe('')
36
+ })
37
+
38
+ it('clears validation removes error', () => {
39
+ const wrapper = mount(DatametriaFormItem)
40
+ wrapper.vm.clearValidate()
41
+ expect(wrapper.vm.errorMessage).toBe('')
42
+ })
43
+
44
+ it('exposes validate method', () => {
45
+ const wrapper = mount(DatametriaFormItem)
46
+ expect(wrapper.vm.validate).toBeDefined()
47
+ })
48
+
49
+ it('exposes reset method', () => {
50
+ const wrapper = mount(DatametriaFormItem)
51
+ expect(wrapper.vm.reset).toBeDefined()
52
+ })
53
+
54
+ it('exposes clearValidate method', () => {
55
+ const wrapper = mount(DatametriaFormItem)
56
+ expect(wrapper.vm.clearValidate).toBeDefined()
57
+ })
58
+ })
@@ -1,31 +1,31 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { mount } from '@vue/test-utils'
3
- import DatametriaGrid from '../DatametriaGrid.vue'
4
-
5
- describe('DatametriaGrid', () => {
6
- it('renders correctly', () => {
7
- const wrapper = mount(DatametriaGrid)
8
- expect(wrapper.find('.dm-grid').exists()).toBe(true)
9
- })
10
-
11
- it('applies custom cols', () => {
12
- const wrapper = mount(DatametriaGrid, {
13
- props: { cols: 6 }
14
- })
15
- expect(wrapper.find('.dm-grid').attributes('style')).toContain('--dm-grid-cols: 6')
16
- })
17
-
18
- it('applies custom gap', () => {
19
- const wrapper = mount(DatametriaGrid, {
20
- props: { gap: '2rem' }
21
- })
22
- expect(wrapper.find('.dm-grid').attributes('style')).toContain('--dm-grid-gap: 2rem')
23
- })
24
-
25
- it('renders slot content', () => {
26
- const wrapper = mount(DatametriaGrid, {
27
- slots: { default: '<div>Grid Item</div>' }
28
- })
29
- expect(wrapper.html()).toContain('Grid Item')
30
- })
31
- })
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import DatametriaGrid from '../DatametriaGrid.vue'
4
+
5
+ describe('DatametriaGrid', () => {
6
+ it('renders correctly', () => {
7
+ const wrapper = mount(DatametriaGrid)
8
+ expect(wrapper.find('.dm-grid').exists()).toBe(true)
9
+ })
10
+
11
+ it('applies custom cols', () => {
12
+ const wrapper = mount(DatametriaGrid, {
13
+ props: { cols: 6 }
14
+ })
15
+ expect(wrapper.find('.dm-grid').attributes('style')).toContain('--dm-grid-cols: 6')
16
+ })
17
+
18
+ it('applies custom gap', () => {
19
+ const wrapper = mount(DatametriaGrid, {
20
+ props: { gap: '2rem' }
21
+ })
22
+ expect(wrapper.find('.dm-grid').attributes('style')).toContain('--dm-grid-gap: 2rem')
23
+ })
24
+
25
+ it('renders slot content', () => {
26
+ const wrapper = mount(DatametriaGrid, {
27
+ slots: { default: '<div>Grid Item</div>' }
28
+ })
29
+ expect(wrapper.html()).toContain('Grid Item')
30
+ })
31
+ })
@@ -1,72 +1,72 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { mount } from '@vue/test-utils'
3
- import DatametriaInput from '../DatametriaInput.vue'
4
-
5
- describe('DatametriaInput', () => {
6
- it('renders correctly', () => {
7
- const wrapper = mount(DatametriaInput)
8
- expect(wrapper.find('.datametria-input').exists()).toBe(true)
9
- })
10
-
11
- it('renders label when provided', () => {
12
- const wrapper = mount(DatametriaInput, {
13
- props: { label: 'Test Label' }
14
- })
15
- expect(wrapper.find('.datametria-input__label').text()).toContain('Test Label')
16
- })
17
-
18
- it('shows required asterisk when required', () => {
19
- const wrapper = mount(DatametriaInput, {
20
- props: { label: 'Test', required: true }
21
- })
22
- expect(wrapper.find('.datametria-input__required').exists()).toBe(true)
23
- })
24
-
25
- it('binds modelValue correctly', () => {
26
- const wrapper = mount(DatametriaInput, {
27
- props: { modelValue: 'test value' }
28
- })
29
- expect((wrapper.find('input').element as HTMLInputElement).value).toBe('test value')
30
- })
31
-
32
- it('emits update:modelValue on input', async () => {
33
- const wrapper = mount(DatametriaInput)
34
- const input = wrapper.find('input')
35
- await input.setValue('new value')
36
- expect(wrapper.emitted('update:modelValue')?.[0]).toEqual(['new value'])
37
- })
38
-
39
- it('applies disabled state', () => {
40
- const wrapper = mount(DatametriaInput, {
41
- props: { disabled: true }
42
- })
43
- expect(wrapper.find('input').attributes('disabled')).toBeDefined()
44
- })
45
-
46
- it('shows error message when provided', () => {
47
- const wrapper = mount(DatametriaInput, {
48
- props: { errorMessage: 'Error text' }
49
- })
50
- expect(wrapper.find('.datametria-input__error').text()).toBe('Error text')
51
- })
52
-
53
- it('applies error class when error exists', () => {
54
- const wrapper = mount(DatametriaInput, {
55
- props: { errorMessage: 'Error' }
56
- })
57
- expect(wrapper.find('.datametria-input__field--error').exists()).toBe(true)
58
- })
59
-
60
- it('applies placeholder', () => {
61
- const wrapper = mount(DatametriaInput, {
62
- props: { placeholder: 'Enter text' }
63
- })
64
- expect(wrapper.find('input').attributes('placeholder')).toBe('Enter text')
65
- })
66
-
67
- it('uses CSS variables with fallbacks', () => {
68
- const wrapper = mount(DatametriaInput)
69
- const styles = wrapper.find('.datametria-input').attributes('style')
70
- expect(wrapper.html()).toContain('datametria-input')
71
- })
72
- })
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import DatametriaInput from '../DatametriaInput.vue'
4
+
5
+ describe('DatametriaInput', () => {
6
+ it('renders correctly', () => {
7
+ const wrapper = mount(DatametriaInput)
8
+ expect(wrapper.find('.datametria-input').exists()).toBe(true)
9
+ })
10
+
11
+ it('renders label when provided', () => {
12
+ const wrapper = mount(DatametriaInput, {
13
+ props: { label: 'Test Label' }
14
+ })
15
+ expect(wrapper.find('.datametria-input__label').text()).toContain('Test Label')
16
+ })
17
+
18
+ it('shows required asterisk when required', () => {
19
+ const wrapper = mount(DatametriaInput, {
20
+ props: { label: 'Test', required: true }
21
+ })
22
+ expect(wrapper.find('.datametria-input__required').exists()).toBe(true)
23
+ })
24
+
25
+ it('binds modelValue correctly', () => {
26
+ const wrapper = mount(DatametriaInput, {
27
+ props: { modelValue: 'test value' }
28
+ })
29
+ expect((wrapper.find('input').element as HTMLInputElement).value).toBe('test value')
30
+ })
31
+
32
+ it('emits update:modelValue on input', async () => {
33
+ const wrapper = mount(DatametriaInput)
34
+ const input = wrapper.find('input')
35
+ await input.setValue('new value')
36
+ expect(wrapper.emitted('update:modelValue')?.[0]).toEqual(['new value'])
37
+ })
38
+
39
+ it('applies disabled state', () => {
40
+ const wrapper = mount(DatametriaInput, {
41
+ props: { disabled: true }
42
+ })
43
+ expect(wrapper.find('input').attributes('disabled')).toBeDefined()
44
+ })
45
+
46
+ it('shows error message when provided', () => {
47
+ const wrapper = mount(DatametriaInput, {
48
+ props: { errorMessage: 'Error text' }
49
+ })
50
+ expect(wrapper.find('.datametria-input__error').text()).toBe('Error text')
51
+ })
52
+
53
+ it('applies error class when error exists', () => {
54
+ const wrapper = mount(DatametriaInput, {
55
+ props: { errorMessage: 'Error' }
56
+ })
57
+ expect(wrapper.find('.datametria-input__field--error').exists()).toBe(true)
58
+ })
59
+
60
+ it('applies placeholder', () => {
61
+ const wrapper = mount(DatametriaInput, {
62
+ props: { placeholder: 'Enter text' }
63
+ })
64
+ expect(wrapper.find('input').attributes('placeholder')).toBe('Enter text')
65
+ })
66
+
67
+ it('uses CSS variables with fallbacks', () => {
68
+ const wrapper = mount(DatametriaInput)
69
+ const styles = wrapper.find('.datametria-input').attributes('style')
70
+ expect(wrapper.html()).toContain('datametria-input')
71
+ })
72
+ })