@datametria/vue-components 2.3.1 → 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 -102
- 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
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest'
|
|
2
|
-
import { mount } from '@vue/test-utils'
|
|
3
|
-
import DatametriaChip from '../DatametriaChip.vue'
|
|
4
|
-
|
|
5
|
-
describe('DatametriaChip', () => {
|
|
6
|
-
it('renders with primary variant by default', () => {
|
|
7
|
-
const wrapper = mount(DatametriaChip, {
|
|
8
|
-
props: { label: 'Test' }
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
expect(wrapper.classes()).toContain('dm-chip--primary')
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('validates invalid variant in development', () => {
|
|
15
|
-
const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
|
16
|
-
const originalEnv = process.env.NODE_ENV
|
|
17
|
-
process.env.NODE_ENV = 'development'
|
|
18
|
-
|
|
19
|
-
mount(DatametriaChip, {
|
|
20
|
-
props: { label: 'Test', variant: 'invalid' }
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
expect(consoleSpy).toHaveBeenCalledWith(
|
|
24
|
-
expect.stringContaining('[DatametriaChip] Invalid variant "invalid"')
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
process.env.NODE_ENV = originalEnv
|
|
28
|
-
consoleSpy.mockRestore()
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('emits click event when clickable', async () => {
|
|
32
|
-
const wrapper = mount(DatametriaChip, {
|
|
33
|
-
props: { label: 'Test', clickable: true }
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
await wrapper.trigger('click')
|
|
37
|
-
expect(wrapper.emitted('click')).toBeTruthy()
|
|
38
|
-
})
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import DatametriaChip from '../DatametriaChip.vue'
|
|
4
|
+
|
|
5
|
+
describe('DatametriaChip', () => {
|
|
6
|
+
it('renders with primary variant by default', () => {
|
|
7
|
+
const wrapper = mount(DatametriaChip, {
|
|
8
|
+
props: { label: 'Test' }
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
expect(wrapper.classes()).toContain('dm-chip--primary')
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('validates invalid variant in development', () => {
|
|
15
|
+
const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
|
16
|
+
const originalEnv = process.env.NODE_ENV
|
|
17
|
+
process.env.NODE_ENV = 'development'
|
|
18
|
+
|
|
19
|
+
mount(DatametriaChip, {
|
|
20
|
+
props: { label: 'Test', variant: 'invalid' }
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
|
24
|
+
expect.stringContaining('[DatametriaChip] Invalid variant "invalid"')
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
process.env.NODE_ENV = originalEnv
|
|
28
|
+
consoleSpy.mockRestore()
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('emits click event when clickable', async () => {
|
|
32
|
+
const wrapper = mount(DatametriaChip, {
|
|
33
|
+
props: { label: 'Test', clickable: true }
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
await wrapper.trigger('click')
|
|
37
|
+
expect(wrapper.emitted('click')).toBeTruthy()
|
|
38
|
+
})
|
|
39
39
|
})
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { mount } from '@vue/test-utils'
|
|
3
|
-
import DatametriaContainer from '../DatametriaContainer.vue'
|
|
4
|
-
|
|
5
|
-
describe('DatametriaContainer', () => {
|
|
6
|
-
it('renders correctly', () => {
|
|
7
|
-
const wrapper = mount(DatametriaContainer)
|
|
8
|
-
expect(wrapper.find('.dm-container').exists()).toBe(true)
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('applies sm size class', () => {
|
|
12
|
-
const wrapper = mount(DatametriaContainer, {
|
|
13
|
-
props: { size: 'sm' }
|
|
14
|
-
})
|
|
15
|
-
expect(wrapper.find('.dm-container--sm').exists()).toBe(true)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it('applies md size class', () => {
|
|
19
|
-
const wrapper = mount(DatametriaContainer, {
|
|
20
|
-
props: { size: 'md' }
|
|
21
|
-
})
|
|
22
|
-
expect(wrapper.find('.dm-container--md').exists()).toBe(true)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
it('applies lg size class', () => {
|
|
26
|
-
const wrapper = mount(DatametriaContainer, {
|
|
27
|
-
props: { size: 'lg' }
|
|
28
|
-
})
|
|
29
|
-
expect(wrapper.find('.dm-container--lg').exists()).toBe(true)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('applies xl size class', () => {
|
|
33
|
-
const wrapper = mount(DatametriaContainer, {
|
|
34
|
-
props: { size: 'xl' }
|
|
35
|
-
})
|
|
36
|
-
expect(wrapper.find('.dm-container--xl').exists()).toBe(true)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('applies fluid class', () => {
|
|
40
|
-
const wrapper = mount(DatametriaContainer, {
|
|
41
|
-
props: { fluid: true }
|
|
42
|
-
})
|
|
43
|
-
expect(wrapper.find('.dm-container--fluid').exists()).toBe(true)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('renders slot content', () => {
|
|
47
|
-
const wrapper = mount(DatametriaContainer, {
|
|
48
|
-
slots: { default: '<div>Content</div>' }
|
|
49
|
-
})
|
|
50
|
-
expect(wrapper.html()).toContain('Content')
|
|
51
|
-
})
|
|
52
|
-
})
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import DatametriaContainer from '../DatametriaContainer.vue'
|
|
4
|
+
|
|
5
|
+
describe('DatametriaContainer', () => {
|
|
6
|
+
it('renders correctly', () => {
|
|
7
|
+
const wrapper = mount(DatametriaContainer)
|
|
8
|
+
expect(wrapper.find('.dm-container').exists()).toBe(true)
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('applies sm size class', () => {
|
|
12
|
+
const wrapper = mount(DatametriaContainer, {
|
|
13
|
+
props: { size: 'sm' }
|
|
14
|
+
})
|
|
15
|
+
expect(wrapper.find('.dm-container--sm').exists()).toBe(true)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('applies md size class', () => {
|
|
19
|
+
const wrapper = mount(DatametriaContainer, {
|
|
20
|
+
props: { size: 'md' }
|
|
21
|
+
})
|
|
22
|
+
expect(wrapper.find('.dm-container--md').exists()).toBe(true)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('applies lg size class', () => {
|
|
26
|
+
const wrapper = mount(DatametriaContainer, {
|
|
27
|
+
props: { size: 'lg' }
|
|
28
|
+
})
|
|
29
|
+
expect(wrapper.find('.dm-container--lg').exists()).toBe(true)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('applies xl size class', () => {
|
|
33
|
+
const wrapper = mount(DatametriaContainer, {
|
|
34
|
+
props: { size: 'xl' }
|
|
35
|
+
})
|
|
36
|
+
expect(wrapper.find('.dm-container--xl').exists()).toBe(true)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('applies fluid class', () => {
|
|
40
|
+
const wrapper = mount(DatametriaContainer, {
|
|
41
|
+
props: { fluid: true }
|
|
42
|
+
})
|
|
43
|
+
expect(wrapper.find('.dm-container--fluid').exists()).toBe(true)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('renders slot content', () => {
|
|
47
|
+
const wrapper = mount(DatametriaContainer, {
|
|
48
|
+
slots: { default: '<div>Content</div>' }
|
|
49
|
+
})
|
|
50
|
+
expect(wrapper.html()).toContain('Content')
|
|
51
|
+
})
|
|
52
|
+
})
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import DatametriaDialog from '../DatametriaDialog.vue'
|
|
4
|
+
|
|
5
|
+
describe('DatametriaDialog', () => {
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
document.body.innerHTML = '<div id="app"></div>'
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
document.body.innerHTML = ''
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('renders correctly when visible', async () => {
|
|
15
|
+
const wrapper = mount(DatametriaDialog, {
|
|
16
|
+
props: {
|
|
17
|
+
modelValue: true,
|
|
18
|
+
title: 'Test Dialog'
|
|
19
|
+
},
|
|
20
|
+
attachTo: document.body
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
await wrapper.vm.$nextTick()
|
|
24
|
+
|
|
25
|
+
expect(document.querySelector('.datametria-dialog')).toBeTruthy()
|
|
26
|
+
expect(document.querySelector('.datametria-dialog__title')?.textContent).toBe('Test Dialog')
|
|
27
|
+
|
|
28
|
+
wrapper.unmount()
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('does not render when modelValue is false', async () => {
|
|
32
|
+
const wrapper = mount(DatametriaDialog, {
|
|
33
|
+
props: {
|
|
34
|
+
modelValue: false
|
|
35
|
+
},
|
|
36
|
+
attachTo: document.body
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
await wrapper.vm.$nextTick()
|
|
40
|
+
|
|
41
|
+
expect(document.querySelector('.datametria-dialog')).toBeFalsy()
|
|
42
|
+
|
|
43
|
+
wrapper.unmount()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('emits update:modelValue when close button is clicked', async () => {
|
|
47
|
+
const wrapper = mount(DatametriaDialog, {
|
|
48
|
+
props: {
|
|
49
|
+
modelValue: true,
|
|
50
|
+
title: 'Test'
|
|
51
|
+
},
|
|
52
|
+
attachTo: document.body
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
await wrapper.vm.$nextTick()
|
|
56
|
+
|
|
57
|
+
const closeBtn = document.querySelector('.datametria-dialog__close') as HTMLElement
|
|
58
|
+
closeBtn?.click()
|
|
59
|
+
|
|
60
|
+
await wrapper.vm.$nextTick()
|
|
61
|
+
|
|
62
|
+
expect(wrapper.emitted('update:modelValue')).toBeTruthy()
|
|
63
|
+
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([false])
|
|
64
|
+
expect(wrapper.emitted('close')).toBeTruthy()
|
|
65
|
+
|
|
66
|
+
wrapper.unmount()
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('emits update:modelValue when overlay is clicked and closeOnClickModal is true', async () => {
|
|
70
|
+
const wrapper = mount(DatametriaDialog, {
|
|
71
|
+
props: {
|
|
72
|
+
modelValue: true,
|
|
73
|
+
closeOnClickModal: true
|
|
74
|
+
},
|
|
75
|
+
attachTo: document.body
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
await wrapper.vm.$nextTick()
|
|
79
|
+
|
|
80
|
+
const overlay = document.querySelector('.datametria-dialog-overlay') as HTMLElement
|
|
81
|
+
overlay?.click()
|
|
82
|
+
|
|
83
|
+
await wrapper.vm.$nextTick()
|
|
84
|
+
|
|
85
|
+
expect(wrapper.emitted('update:modelValue')).toBeTruthy()
|
|
86
|
+
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([false])
|
|
87
|
+
|
|
88
|
+
wrapper.unmount()
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('does not emit update:modelValue when overlay is clicked and closeOnClickModal is false', async () => {
|
|
92
|
+
const wrapper = mount(DatametriaDialog, {
|
|
93
|
+
props: {
|
|
94
|
+
modelValue: true,
|
|
95
|
+
closeOnClickModal: false
|
|
96
|
+
},
|
|
97
|
+
attachTo: document.body
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
await wrapper.vm.$nextTick()
|
|
101
|
+
|
|
102
|
+
const overlay = document.querySelector('.datametria-dialog-overlay') as HTMLElement
|
|
103
|
+
overlay?.click()
|
|
104
|
+
|
|
105
|
+
await wrapper.vm.$nextTick()
|
|
106
|
+
|
|
107
|
+
expect(wrapper.emitted('update:modelValue')).toBeFalsy()
|
|
108
|
+
|
|
109
|
+
wrapper.unmount()
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('does not close when dialog content is clicked', async () => {
|
|
113
|
+
const wrapper = mount(DatametriaDialog, {
|
|
114
|
+
props: {
|
|
115
|
+
modelValue: true,
|
|
116
|
+
closeOnClickModal: true
|
|
117
|
+
},
|
|
118
|
+
attachTo: document.body
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
await wrapper.vm.$nextTick()
|
|
122
|
+
|
|
123
|
+
const dialog = document.querySelector('.datametria-dialog') as HTMLElement
|
|
124
|
+
dialog?.click()
|
|
125
|
+
|
|
126
|
+
await wrapper.vm.$nextTick()
|
|
127
|
+
|
|
128
|
+
expect(wrapper.emitted('update:modelValue')).toBeFalsy()
|
|
129
|
+
|
|
130
|
+
wrapper.unmount()
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
it('applies fullscreen class when fullscreen prop is true', async () => {
|
|
134
|
+
const wrapper = mount(DatametriaDialog, {
|
|
135
|
+
props: {
|
|
136
|
+
modelValue: true,
|
|
137
|
+
fullscreen: true
|
|
138
|
+
},
|
|
139
|
+
attachTo: document.body
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
await wrapper.vm.$nextTick()
|
|
143
|
+
|
|
144
|
+
expect(document.querySelector('.datametria-dialog--fullscreen')).toBeTruthy()
|
|
145
|
+
|
|
146
|
+
wrapper.unmount()
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('applies custom width', async () => {
|
|
150
|
+
const wrapper = mount(DatametriaDialog, {
|
|
151
|
+
props: {
|
|
152
|
+
modelValue: true,
|
|
153
|
+
width: '800px'
|
|
154
|
+
},
|
|
155
|
+
attachTo: document.body
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
await wrapper.vm.$nextTick()
|
|
159
|
+
|
|
160
|
+
const dialog = document.querySelector('.datametria-dialog') as HTMLElement
|
|
161
|
+
expect(dialog?.style.width).toBe('800px')
|
|
162
|
+
|
|
163
|
+
wrapper.unmount()
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
it('applies numeric width as pixels', async () => {
|
|
167
|
+
const wrapper = mount(DatametriaDialog, {
|
|
168
|
+
props: {
|
|
169
|
+
modelValue: true,
|
|
170
|
+
width: 600
|
|
171
|
+
},
|
|
172
|
+
attachTo: document.body
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
await wrapper.vm.$nextTick()
|
|
176
|
+
|
|
177
|
+
const dialog = document.querySelector('.datametria-dialog') as HTMLElement
|
|
178
|
+
expect(dialog?.style.width).toBe('600px')
|
|
179
|
+
|
|
180
|
+
wrapper.unmount()
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
it('renders header slot content', async () => {
|
|
184
|
+
const wrapper = mount(DatametriaDialog, {
|
|
185
|
+
props: {
|
|
186
|
+
modelValue: true
|
|
187
|
+
},
|
|
188
|
+
slots: {
|
|
189
|
+
header: '<div class="custom-header">Custom Header</div>'
|
|
190
|
+
},
|
|
191
|
+
attachTo: document.body
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
await wrapper.vm.$nextTick()
|
|
195
|
+
|
|
196
|
+
expect(document.querySelector('.custom-header')?.textContent).toBe('Custom Header')
|
|
197
|
+
|
|
198
|
+
wrapper.unmount()
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
it('renders default slot content', async () => {
|
|
202
|
+
const wrapper = mount(DatametriaDialog, {
|
|
203
|
+
props: {
|
|
204
|
+
modelValue: true
|
|
205
|
+
},
|
|
206
|
+
slots: {
|
|
207
|
+
default: '<p class="content">Dialog Content</p>'
|
|
208
|
+
},
|
|
209
|
+
attachTo: document.body
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
await wrapper.vm.$nextTick()
|
|
213
|
+
|
|
214
|
+
expect(document.querySelector('.content')?.textContent).toBe('Dialog Content')
|
|
215
|
+
|
|
216
|
+
wrapper.unmount()
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
it('renders footer slot content', async () => {
|
|
220
|
+
const wrapper = mount(DatametriaDialog, {
|
|
221
|
+
props: {
|
|
222
|
+
modelValue: true
|
|
223
|
+
},
|
|
224
|
+
slots: {
|
|
225
|
+
footer: '<button class="custom-btn">OK</button>'
|
|
226
|
+
},
|
|
227
|
+
attachTo: document.body
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
await wrapper.vm.$nextTick()
|
|
231
|
+
|
|
232
|
+
expect(document.querySelector('.custom-btn')?.textContent).toBe('OK')
|
|
233
|
+
|
|
234
|
+
wrapper.unmount()
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
it('does not show close button when showClose is false', async () => {
|
|
238
|
+
const wrapper = mount(DatametriaDialog, {
|
|
239
|
+
props: {
|
|
240
|
+
modelValue: true,
|
|
241
|
+
showClose: false
|
|
242
|
+
},
|
|
243
|
+
attachTo: document.body
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
await wrapper.vm.$nextTick()
|
|
247
|
+
|
|
248
|
+
expect(document.querySelector('.datametria-dialog__close')).toBeFalsy()
|
|
249
|
+
|
|
250
|
+
wrapper.unmount()
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
it('applies center class when center prop is true', async () => {
|
|
254
|
+
const wrapper = mount(DatametriaDialog, {
|
|
255
|
+
props: {
|
|
256
|
+
modelValue: true,
|
|
257
|
+
center: true
|
|
258
|
+
},
|
|
259
|
+
attachTo: document.body
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
await wrapper.vm.$nextTick()
|
|
263
|
+
|
|
264
|
+
expect(document.querySelector('.datametria-dialog--center')).toBeTruthy()
|
|
265
|
+
|
|
266
|
+
wrapper.unmount()
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
// beforeClose tests removed - edge case complex to test with Teleport
|
|
270
|
+
|
|
271
|
+
it('emits open and opened events when dialog opens', async () => {
|
|
272
|
+
const wrapper = mount(DatametriaDialog, {
|
|
273
|
+
props: {
|
|
274
|
+
modelValue: false
|
|
275
|
+
}
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
await wrapper.setProps({ modelValue: true })
|
|
279
|
+
|
|
280
|
+
expect(wrapper.emitted('open')).toBeTruthy()
|
|
281
|
+
|
|
282
|
+
// Wait for opened event (300ms delay)
|
|
283
|
+
await new Promise(resolve => setTimeout(resolve, 350))
|
|
284
|
+
expect(wrapper.emitted('opened')).toBeTruthy()
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
it('emits closed event when dialog closes', async () => {
|
|
288
|
+
const wrapper = mount(DatametriaDialog, {
|
|
289
|
+
props: {
|
|
290
|
+
modelValue: true
|
|
291
|
+
}
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
await wrapper.setProps({ modelValue: false })
|
|
295
|
+
|
|
296
|
+
// Wait for closed event (300ms delay)
|
|
297
|
+
await new Promise(resolve => setTimeout(resolve, 350))
|
|
298
|
+
expect(wrapper.emitted('closed')).toBeTruthy()
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
it('has proper ARIA attributes', async () => {
|
|
302
|
+
const wrapper = mount(DatametriaDialog, {
|
|
303
|
+
props: {
|
|
304
|
+
modelValue: true,
|
|
305
|
+
title: 'Accessible Dialog'
|
|
306
|
+
},
|
|
307
|
+
attachTo: document.body
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
await wrapper.vm.$nextTick()
|
|
311
|
+
|
|
312
|
+
const dialog = document.querySelector('.datametria-dialog')
|
|
313
|
+
expect(dialog?.getAttribute('role')).toBe('dialog')
|
|
314
|
+
expect(dialog?.getAttribute('aria-modal')).toBe('true')
|
|
315
|
+
expect(dialog?.getAttribute('aria-labelledby')).toBeTruthy()
|
|
316
|
+
|
|
317
|
+
wrapper.unmount()
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
it('close button has proper aria-label', async () => {
|
|
321
|
+
const wrapper = mount(DatametriaDialog, {
|
|
322
|
+
props: {
|
|
323
|
+
modelValue: true,
|
|
324
|
+
title: 'Test'
|
|
325
|
+
},
|
|
326
|
+
attachTo: document.body
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
await wrapper.vm.$nextTick()
|
|
330
|
+
await new Promise(resolve => setTimeout(resolve, 100))
|
|
331
|
+
|
|
332
|
+
const closeBtn = document.querySelector('.datametria-dialog__close')
|
|
333
|
+
expect(closeBtn).toBeTruthy()
|
|
334
|
+
expect(closeBtn?.getAttribute('aria-label')).toBe('Fechar')
|
|
335
|
+
|
|
336
|
+
wrapper.unmount()
|
|
337
|
+
})
|
|
338
|
+
})
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { mount } from '@vue/test-utils'
|
|
3
|
-
import DatametriaDivider from '../DatametriaDivider.vue'
|
|
4
|
-
|
|
5
|
-
describe('DatametriaDivider', () => {
|
|
6
|
-
it('renders horizontal by default', () => {
|
|
7
|
-
const wrapper = mount(DatametriaDivider)
|
|
8
|
-
expect(wrapper.find('.dm-divider--horizontal').exists()).toBe(true)
|
|
9
|
-
expect(wrapper.attributes('role')).toBe('separator')
|
|
10
|
-
expect(wrapper.attributes('aria-orientation')).toBe('horizontal')
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('renders vertical orientation', () => {
|
|
14
|
-
const wrapper = mount(DatametriaDivider, {
|
|
15
|
-
props: { orientation: 'vertical' }
|
|
16
|
-
})
|
|
17
|
-
expect(wrapper.find('.dm-divider--vertical').exists()).toBe(true)
|
|
18
|
-
expect(wrapper.attributes('aria-orientation')).toBe('vertical')
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('renders with label prop', () => {
|
|
22
|
-
const wrapper = mount(DatametriaDivider, {
|
|
23
|
-
props: { label: 'OR' }
|
|
24
|
-
})
|
|
25
|
-
expect(wrapper.find('.dm-divider__label').text()).toBe('OR')
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('renders slot content', () => {
|
|
29
|
-
const wrapper = mount(DatametriaDivider, {
|
|
30
|
-
slots: { default: '<strong>Custom</strong>' }
|
|
31
|
-
})
|
|
32
|
-
expect(wrapper.html()).toContain('<strong>Custom</strong>')
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('renders dashed style', () => {
|
|
36
|
-
const wrapper = mount(DatametriaDivider, {
|
|
37
|
-
props: { dashed: true }
|
|
38
|
-
})
|
|
39
|
-
expect(wrapper.find('.dm-divider--dashed').exists()).toBe(true)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it('renders solid style by default', () => {
|
|
43
|
-
const wrapper = mount(DatametriaDivider)
|
|
44
|
-
expect(wrapper.find('.dm-divider--dashed').exists()).toBe(false)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('works without ThemeProvider', () => {
|
|
48
|
-
const wrapper = mount(DatametriaDivider, {
|
|
49
|
-
props: { label: 'Test', orientation: 'horizontal' }
|
|
50
|
-
})
|
|
51
|
-
expect(wrapper.find('.dm-divider--horizontal').exists()).toBe(true)
|
|
52
|
-
expect(wrapper.text()).toBe('Test')
|
|
53
|
-
})
|
|
54
|
-
})
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import DatametriaDivider from '../DatametriaDivider.vue'
|
|
4
|
+
|
|
5
|
+
describe('DatametriaDivider', () => {
|
|
6
|
+
it('renders horizontal by default', () => {
|
|
7
|
+
const wrapper = mount(DatametriaDivider)
|
|
8
|
+
expect(wrapper.find('.dm-divider--horizontal').exists()).toBe(true)
|
|
9
|
+
expect(wrapper.attributes('role')).toBe('separator')
|
|
10
|
+
expect(wrapper.attributes('aria-orientation')).toBe('horizontal')
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('renders vertical orientation', () => {
|
|
14
|
+
const wrapper = mount(DatametriaDivider, {
|
|
15
|
+
props: { orientation: 'vertical' }
|
|
16
|
+
})
|
|
17
|
+
expect(wrapper.find('.dm-divider--vertical').exists()).toBe(true)
|
|
18
|
+
expect(wrapper.attributes('aria-orientation')).toBe('vertical')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('renders with label prop', () => {
|
|
22
|
+
const wrapper = mount(DatametriaDivider, {
|
|
23
|
+
props: { label: 'OR' }
|
|
24
|
+
})
|
|
25
|
+
expect(wrapper.find('.dm-divider__label').text()).toBe('OR')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('renders slot content', () => {
|
|
29
|
+
const wrapper = mount(DatametriaDivider, {
|
|
30
|
+
slots: { default: '<strong>Custom</strong>' }
|
|
31
|
+
})
|
|
32
|
+
expect(wrapper.html()).toContain('<strong>Custom</strong>')
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('renders dashed style', () => {
|
|
36
|
+
const wrapper = mount(DatametriaDivider, {
|
|
37
|
+
props: { dashed: true }
|
|
38
|
+
})
|
|
39
|
+
expect(wrapper.find('.dm-divider--dashed').exists()).toBe(true)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('renders solid style by default', () => {
|
|
43
|
+
const wrapper = mount(DatametriaDivider)
|
|
44
|
+
expect(wrapper.find('.dm-divider--dashed').exists()).toBe(false)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('works without ThemeProvider', () => {
|
|
48
|
+
const wrapper = mount(DatametriaDivider, {
|
|
49
|
+
props: { label: 'Test', orientation: 'horizontal' }
|
|
50
|
+
})
|
|
51
|
+
expect(wrapper.find('.dm-divider--horizontal').exists()).toBe(true)
|
|
52
|
+
expect(wrapper.text()).toBe('Test')
|
|
53
|
+
})
|
|
54
|
+
})
|