@zap-wunschlachen/wl-shared-components 1.0.24 → 1.0.26
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/.github/workflows/playwright.yml +205 -205
- package/.github/workflows/static.yml +61 -61
- package/.github/workflows/update-snapshots.yml +37 -37
- package/.prettierrc +5 -5
- package/.storybook/main.ts +18 -18
- package/.storybook/preview.ts +37 -37
- package/.storybook/storyWrapper.vue +18 -18
- package/.storybook/withVuetifyTheme.decorator.ts +21 -21
- package/App.vue +34 -176
- package/README.md +56 -56
- package/heroicons.ts +75 -75
- package/index.html +19 -19
- package/package.json +67 -67
- package/playwright.config.ts +48 -48
- package/public/background.svg +60 -60
- package/public/style.css +187 -187
- package/public/technologies.svg +22 -22
- package/src/assets/css/base.css +235 -235
- package/src/assets/css/variables.css +107 -96
- package/src/components/Accordion/Accordion.css +59 -59
- package/src/components/Accordion/AccordionGroup.vue +51 -51
- package/src/components/Accordion/AccordionItem.vue +66 -66
- package/src/components/Appointment/Card/Actions.css +54 -54
- package/src/components/Appointment/Card/Actions.vue +99 -99
- package/src/components/Appointment/Card/AnamneseNotification.css +15 -15
- package/src/components/Appointment/Card/AnamneseNotification.vue +23 -23
- package/src/components/Appointment/Card/Card.css +80 -80
- package/src/components/Appointment/Card/Card.vue +93 -93
- package/src/components/Appointment/Card/Details.css +50 -50
- package/src/components/Appointment/Card/Details.vue +43 -43
- package/src/components/Audio/Audio.vue +187 -187
- package/src/components/Audio/Waveform.vue +117 -117
- package/src/components/Background/Background.css +39 -0
- package/src/components/Background/Background.vue +19 -0
- package/src/components/Background/WhiteCocoonBackground.vue +9 -0
- package/src/components/Background/WunschlachenBackground.vue +11 -0
- package/src/components/Button/Button.vue +119 -119
- package/src/components/CheckBox/CheckBox.css +185 -185
- package/src/components/CheckBox/Checkbox.vue +130 -130
- package/src/components/DateInput/DateInput.css +2 -2
- package/src/components/DateInput/DateInput.vue +262 -262
- package/src/components/Dialog/Dialog.css +6 -6
- package/src/components/Dialog/Dialog.vue +29 -29
- package/src/components/EditField/EditField.css +19 -19
- package/src/components/EditField/EditField.vue +202 -202
- package/src/components/ErrorPage/ErrorPage.css +124 -0
- package/src/components/ErrorPage/ErrorPage.vue +45 -0
- package/src/components/ErrorPage/ErrorPageLogo.vue +26 -0
- package/src/components/IconBullet/IconBullet.vue +86 -86
- package/src/components/IconBullet/IconBulletList.vue +41 -41
- package/src/components/Icons/AdvanceAppointments.vue +153 -153
- package/src/components/Icons/Audio/CloudFailed.vue +20 -20
- package/src/components/Icons/Audio/CloudSaved.vue +21 -21
- package/src/components/Icons/Audio/Delete.vue +15 -15
- package/src/components/Icons/Audio/Pause.vue +18 -18
- package/src/components/Icons/Audio/Play.vue +15 -15
- package/src/components/Icons/CalendarNotification.vue +126 -126
- package/src/components/Icons/Chair.vue +32 -32
- package/src/components/Icons/ChairNotification.vue +35 -35
- package/src/components/Icons/Circle.vue +66 -66
- package/src/components/Icons/FavIcon.vue +22 -22
- package/src/components/Icons/FilledCircle.vue +11 -11
- package/src/components/Icons/Group3.vue +46 -46
- package/src/components/Icons/Logo.vue +108 -0
- package/src/components/Icons/RingNotification.vue +54 -54
- package/src/components/Icons/SolidArrowRight.vue +14 -14
- package/src/components/Icons/calendar.vue +17 -17
- package/src/components/Icons/checkbox.vue +19 -19
- package/src/components/Icons/outlineChecked.vue +27 -27
- package/src/components/Icons/play.vue +5 -5
- package/src/components/Input/Input.css +187 -187
- package/src/components/Input/Input.vue +247 -247
- package/src/components/Laboratory/AppointmentCard/AppointmentCard.css +7 -7
- package/src/components/Laboratory/AppointmentCard/AppointmentCard.vue +116 -116
- package/src/components/Laboratory/ChatBoxImage/ChatBoxImage.vue +81 -81
- package/src/components/Laboratory/ChatMessage/ChatMessage.vue +113 -113
- package/src/components/Laboratory/ChatMessage/ChatMessageBadge.css +4 -4
- package/src/components/Laboratory/ChatMessage/ChatMessageBadge.vue +99 -99
- package/src/components/Laboratory/ChatNotification/ChatNotification.vue +130 -130
- package/src/components/Laboratory/DocumentCard/DocumentCard.css +3 -3
- package/src/components/Laboratory/DocumentCard/DocumentCard.vue +50 -50
- package/src/components/Laboratory/DocumentCard/DocumentCardItem.vue +53 -53
- package/src/components/Laboratory/InfoCard/InfoCard.vue +162 -162
- package/src/components/Laboratory/MainColumnsBar/MainColumnsBar.vue +102 -102
- package/src/components/Laboratory/ProgressCircle/ProgressCircle.vue +152 -152
- package/src/components/Laboratory/ProgressLinear/ProgressLinear.css +33 -33
- package/src/components/Laboratory/ProgressLinear/ProgressLinear.vue +75 -75
- package/src/components/Laboratory/SelectionColumnBar/SelectionColumnBar.vue +92 -92
- package/src/components/Laboratory/StatusNotification/StatusNotification.vue +49 -49
- package/src/components/Laboratory/TagLabel/TagLabel.vue +126 -126
- package/src/components/Laboratory/TagLabelGroup/TagLabelGroup.vue +97 -97
- package/src/components/Laboratory/TicketCard/TicketCard.css +3 -3
- package/src/components/Laboratory/TicketCard/TicketCard.vue +143 -143
- package/src/components/Laboratory/TimeLine/TimeLineEvent.css +18 -18
- package/src/components/Laboratory/TimeLine/TimeLineEvent.vue +119 -119
- package/src/components/Laboratory/TimeLine/Timeline.css +4 -4
- package/src/components/Laboratory/TimeLine/Timeline.vue +30 -30
- package/src/components/Loader/Loader.css +51 -51
- package/src/components/MaintenanceBanner/MaintenanceBanner.css +289 -0
- package/src/components/MaintenanceBanner/MaintenanceBanner.vue +127 -0
- package/src/components/MaintenanceBanner/MaintenanceIllustration.vue +54 -0
- package/src/components/Modal/Modal.css +5 -5
- package/src/components/Modal/Modal.vue +22 -22
- package/src/components/NotificationBubble/NotificationBubble.css +4 -4
- package/src/components/NotificationBubble/NotificationBubble.vue +90 -90
- package/src/components/OtpInput/OtpInput.css +39 -39
- package/src/components/OtpInput/OtpInput.vue +143 -143
- package/src/components/PhoneInput/PhoneInput.css +31 -31
- package/src/components/PhoneInput/PhoneInput.vue +113 -113
- package/src/components/Select/Select.css +150 -150
- package/src/components/Select/Select.vue +315 -304
- package/src/components/TextArea/TextArea.css +3 -3
- package/src/components/TextArea/TextArea.vue +126 -126
- package/src/components/TickBox/TickBox.css +49 -49
- package/src/components/TickBox/TickBox.vue +126 -126
- package/src/components/index.ts +26 -24
- package/src/constants/iconEnums.ts +3 -3
- package/src/i18n/i18n.ts +15 -15
- package/src/i18n/locales/de.json +30 -30
- package/src/i18n/locales/en.json +30 -30
- package/src/index.ts +34 -34
- package/src/main.ts +11 -11
- package/src/plugins/vuetify.ts +139 -131
- package/src/shims-vue.d.ts +10 -10
- package/src/stories/Accordion.stories.ts +650 -650
- package/src/stories/Audio.stories.ts +28 -28
- package/src/stories/Button.stories.ts +263 -263
- package/src/stories/CheckBox.stories.ts +348 -348
- package/src/stories/DateInput.stories.ts +53 -53
- package/src/stories/Dialog.stories.ts +147 -147
- package/src/stories/EditField.stories.ts +78 -78
- package/src/stories/IconBullet/IconBullet.stories.ts +201 -201
- package/src/stories/IconBullet/IconBulletList.stories.ts +275 -275
- package/src/stories/Input.stories.ts +351 -351
- package/src/stories/Laboratory/Cards/AppointmentCard/AppointmentCard.stories.ts +260 -260
- package/src/stories/Laboratory/Cards/DocumentCard/DocumentCard.stories.ts +176 -176
- package/src/stories/Laboratory/Cards/DocumentCard/DocumentCardItem.stories.ts +119 -119
- package/src/stories/Laboratory/Cards/InfoCard/InfoCard.stories.ts +320 -320
- package/src/stories/Laboratory/Cards/TicketCard/TicketCard.stories.ts +335 -335
- package/src/stories/Laboratory/Chat/ChatBoxImage.stories.ts +82 -82
- package/src/stories/Laboratory/Chat/ChatMessage.stories.ts +198 -198
- package/src/stories/Laboratory/Chat/ChatMessageBadge.stories.ts +204 -204
- package/src/stories/Laboratory/Chat/ChatNotification.stories.ts +144 -144
- package/src/stories/Laboratory/Chat/ProgressLinear.stories.ts +186 -186
- package/src/stories/Laboratory/Chat/StatusNotification.stories.ts +111 -111
- package/src/stories/Laboratory/MainColumnsBar.stories.ts +48 -48
- package/src/stories/Laboratory/ProgressCircle.stories.ts +261 -261
- package/src/stories/Laboratory/SelectionColumnBar.stories.ts +234 -234
- package/src/stories/Laboratory/TagLabel.stories.ts +418 -418
- package/src/stories/Laboratory/TagLabelGroup.stories.ts +234 -234
- package/src/stories/Laboratory/Timeline.stories.ts +403 -403
- package/src/stories/NotificationBubble.stories.ts +194 -194
- package/src/stories/OtpInput.stories.ts +100 -100
- package/src/stories/PhoneInput.stories.ts +52 -52
- package/src/stories/Select.stories.ts +419 -419
- package/src/stories/TextArea.stories.ts +112 -112
- package/src/stories/TickBox.stories.ts +294 -294
- package/src/stories/v-icon.stories.ts +91 -91
- package/src/utils/index.ts +106 -100
- package/src/vite-env.d.ts +1 -1
- package/tests/e2e/README.md +220 -220
- package/tests/e2e/accessibility.spec.ts +638 -638
- package/tests/e2e/accordion.spec.ts +42 -42
- package/tests/e2e/additional-components.spec.ts +437 -437
- package/tests/e2e/all-components.spec.ts +135 -135
- package/tests/e2e/appointment-card.spec.ts +816 -816
- package/tests/e2e/button-fixed.spec.ts +58 -58
- package/tests/e2e/button.spec.ts +76 -76
- package/tests/e2e/checkbox.spec.ts +50 -50
- package/tests/e2e/date-input.spec.ts +46 -46
- package/tests/e2e/debug.spec.ts +51 -51
- package/tests/e2e/dialog.spec.ts +58 -58
- package/tests/e2e/input.spec.ts +55 -55
- package/tests/e2e/laboratory-components.spec.ts +320 -320
- package/tests/e2e/otp-input.spec.ts +50 -50
- package/tests/e2e/select.spec.ts +52 -52
- package/tests/e2e/storybook-utils.ts +59 -59
- package/tests/e2e/test-basic.spec.ts +33 -33
- package/tests/e2e/visual-regression.spec.ts +350 -350
- package/tests/unit/components/Accordion/AccordionGroup.spec.ts.skip +342 -342
- package/tests/unit/components/Accordion/AccordionItem.spec.ts.skip +383 -383
- package/tests/unit/components/Appointment/Card/Actions.spec.ts +407 -407
- package/tests/unit/components/Appointment/Card/Card.spec.ts +485 -485
- package/tests/unit/components/Appointment/Card/Details.spec.ts +397 -397
- package/tests/unit/components/Audio/Audio.spec.ts +403 -403
- package/tests/unit/components/Audio/Waveform.spec.ts +483 -483
- package/tests/unit/components/Core/Button.spec.ts +336 -336
- package/tests/unit/components/Core/Checkbox.spec.ts +544 -544
- package/tests/unit/components/Core/DateInput.spec.ts +690 -690
- package/tests/unit/components/Core/Dialog.spec.ts +485 -485
- package/tests/unit/components/Core/EditField.spec.ts +782 -782
- package/tests/unit/components/Core/Input.spec.ts +512 -512
- package/tests/unit/components/Core/Modal.spec.ts +518 -518
- package/tests/unit/components/Core/NotificationBubble.spec.ts +606 -606
- package/tests/unit/components/Core/OtpInput.spec.ts +708 -708
- package/tests/unit/components/Core/PhoneInput.spec.ts +619 -619
- package/tests/unit/components/Core/Select.spec.ts +712 -712
- package/tests/unit/components/Core/TextArea.spec.ts +565 -565
- package/tests/unit/components/Core/TickBox.spec.ts +779 -779
- package/tests/unit/components/IconBullet/IconBullet.spec.ts +356 -356
- package/tests/unit/components/IconBullet/IconBulletList.spec.ts +371 -371
- package/tests/unit/components/Icons/Audio/CloudFailed.spec.ts +108 -108
- package/tests/unit/components/Icons/Audio/CloudSaved.spec.ts +149 -149
- package/tests/unit/components/Icons/Audio/Delete.spec.ts +158 -158
- package/tests/unit/components/Icons/Audio/Pause.spec.ts +208 -208
- package/tests/unit/components/Icons/Audio/Play.spec.ts +217 -217
- package/tests/unit/components/Icons/CalendarNotification.spec.ts +186 -186
- package/tests/unit/components/Icons/Chair.spec.ts +234 -234
- package/tests/unit/components/Icons/ChairNotification.spec.ts +311 -311
- package/tests/unit/components/Icons/Circle.spec.ts +255 -255
- package/tests/unit/components/Icons/FavIcon.spec.ts +251 -251
- package/tests/unit/components/Icons/FilledCircle.spec.ts +274 -274
- package/tests/unit/components/Icons/Group3.spec.ts +355 -355
- package/tests/unit/components/Icons/RingNotification.spec.ts +393 -393
- package/tests/unit/components/Icons/calendar.spec.ts +286 -286
- package/tests/unit/components/Icons/checkbox.spec.ts +315 -315
- package/tests/unit/components/Icons/outlineChecked.spec.ts +434 -434
- package/tests/unit/components/Icons/play.spec.ts +308 -308
- package/tests/unit/components/Laboratory/AppointmentCard.spec.ts +167 -167
- package/tests/unit/components/Laboratory/ChatBoxImage.spec.ts +179 -179
- package/tests/unit/components/Laboratory/ChatMessage.spec.ts +263 -263
- package/tests/unit/components/Laboratory/ChatMessageBadge.spec.ts +282 -282
- package/tests/unit/components/Laboratory/ChatNotification.spec.ts +256 -256
- package/tests/unit/components/Laboratory/DocumentCard.spec.ts +228 -228
- package/tests/unit/components/Laboratory/DocumentCardItem.spec.ts +236 -236
- package/tests/unit/components/Laboratory/InfoCard.spec.ts +308 -308
- package/tests/unit/components/Laboratory/MainColumnsBar.spec.ts +251 -251
- package/tests/unit/components/Laboratory/ProgressCircle.spec.ts +290 -290
- package/tests/unit/components/Laboratory/ProgressLinear.spec.ts +275 -275
- package/tests/unit/components/Laboratory/SelectionColumnBar.spec.ts +288 -288
- package/tests/unit/components/Laboratory/StatusNotification.spec.ts +296 -296
- package/tests/unit/components/Laboratory/TagLabel.spec.ts +353 -353
- package/tests/unit/components/Laboratory/TagLabelGroup.spec.ts +377 -377
- package/tests/unit/components/Laboratory/TicketCard.spec.ts +351 -351
- package/tests/unit/components/Laboratory/TimeLineEvent.spec.ts +381 -381
- package/tests/unit/components/Laboratory/Timeline.spec.ts +419 -419
- package/tests/unit/constants/iconEnums.spec.ts +39 -39
- package/tests/unit/i18n/i18n.spec.ts +88 -88
- package/tests/unit/plugins/vuetify.spec.ts +220 -220
- package/tests/unit/setup.ts +189 -189
- package/tests/unit/src/components/index.spec.ts.skip +192 -192
- package/tests/unit/src/index.spec.ts.skip +182 -182
- package/tests/unit/src/main.spec.ts +151 -151
- package/tsconfig.json +26 -26
- package/vite.config.ts +29 -29
- package/vitest.config.ts +83 -83
|
@@ -1,780 +1,780 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { mount } from '@vue/test-utils';
|
|
3
|
-
import TickBox from '@components/TickBox/TickBox.vue';
|
|
4
|
-
|
|
5
|
-
describe('TickBox', () => {
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
vi.clearAllMocks();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
// Test default behavior and rendering
|
|
11
|
-
describe('Default Behavior', () => {
|
|
12
|
-
it('renders with required props', () => {
|
|
13
|
-
const wrapper = mount(TickBox, {
|
|
14
|
-
props: {
|
|
15
|
-
label: 'Test Label',
|
|
16
|
-
modelValue: false
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
expect(wrapper.find('[data-testid="root"]').exists()).toBe(true);
|
|
21
|
-
expect(wrapper.find('.tick-box').exists()).toBe(true);
|
|
22
|
-
expect(wrapper.vm.label).toBe('Test Label');
|
|
23
|
-
expect(wrapper.vm.modelValue).toBe(false);
|
|
24
|
-
expect(wrapper.vm.success).toBe(false);
|
|
25
|
-
expect(wrapper.vm.error).toBe(false);
|
|
26
|
-
expect(wrapper.vm.disabled).toBe(false);
|
|
27
|
-
expect(wrapper.vm.value).toBe(true);
|
|
28
|
-
expect(wrapper.vm.density).toBe('comfortable');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('has data-testid for testing', () => {
|
|
32
|
-
const wrapper = mount(TickBox, {
|
|
33
|
-
props: {
|
|
34
|
-
label: 'Test',
|
|
35
|
-
modelValue: false
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
expect(wrapper.find('[data-testid="root"]').exists()).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('applies tick-box CSS class', () => {
|
|
43
|
-
const wrapper = mount(TickBox, {
|
|
44
|
-
props: {
|
|
45
|
-
label: 'Test',
|
|
46
|
-
modelValue: false
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
expect(wrapper.find('.tick-box').exists()).toBe(true);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('requires label prop', () => {
|
|
54
|
-
// This test verifies that label is marked as required
|
|
55
|
-
const wrapper = mount(TickBox, {
|
|
56
|
-
props: {
|
|
57
|
-
label: 'Required Label',
|
|
58
|
-
modelValue: false
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
expect(wrapper.vm.label).toBe('Required Label');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('requires modelValue prop', () => {
|
|
66
|
-
// This test verifies that modelValue is marked as required
|
|
67
|
-
const wrapper = mount(TickBox, {
|
|
68
|
-
props: {
|
|
69
|
-
label: 'Test',
|
|
70
|
-
modelValue: true
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
expect(wrapper.vm.modelValue).toBe(true);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Test v-model functionality
|
|
79
|
-
describe('v-model', () => {
|
|
80
|
-
it('handles boolean modelValue', () => {
|
|
81
|
-
const wrapper = mount(TickBox, {
|
|
82
|
-
props: {
|
|
83
|
-
label: 'Boolean Test',
|
|
84
|
-
modelValue: true
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
expect(wrapper.vm.internalValue).toBe(true);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('handles false boolean modelValue', () => {
|
|
92
|
-
const wrapper = mount(TickBox, {
|
|
93
|
-
props: {
|
|
94
|
-
label: 'Boolean Test',
|
|
95
|
-
modelValue: false
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
expect(wrapper.vm.internalValue).toBe(false);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('handles array modelValue', () => {
|
|
103
|
-
const wrapper = mount(TickBox, {
|
|
104
|
-
props: {
|
|
105
|
-
label: 'Array Test',
|
|
106
|
-
modelValue: ['option1', 'option2']
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
expect(wrapper.vm.internalValue).toEqual(['option1', 'option2']);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('handles empty array modelValue', () => {
|
|
114
|
-
const wrapper = mount(TickBox, {
|
|
115
|
-
props: {
|
|
116
|
-
label: 'Empty Array Test',
|
|
117
|
-
modelValue: []
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
expect(wrapper.vm.internalValue).toEqual([]);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('emits update:modelValue when internalValue changes', () => {
|
|
125
|
-
const wrapper = mount(TickBox, {
|
|
126
|
-
props: {
|
|
127
|
-
label: 'Emit Test',
|
|
128
|
-
modelValue: false
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
wrapper.vm.internalValue = true;
|
|
133
|
-
|
|
134
|
-
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
|
135
|
-
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([true]);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('updates when modelValue prop changes', async () => {
|
|
139
|
-
const wrapper = mount(TickBox, {
|
|
140
|
-
props: {
|
|
141
|
-
label: 'Update Test',
|
|
142
|
-
modelValue: false
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
expect(wrapper.vm.internalValue).toBe(false);
|
|
147
|
-
|
|
148
|
-
await wrapper.setProps({ modelValue: true });
|
|
149
|
-
|
|
150
|
-
expect(wrapper.vm.internalValue).toBe(true);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('handles array to boolean modelValue changes', async () => {
|
|
154
|
-
const wrapper = mount(TickBox, {
|
|
155
|
-
props: {
|
|
156
|
-
label: 'Type Change Test',
|
|
157
|
-
modelValue: []
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
expect(wrapper.vm.internalValue).toEqual([]);
|
|
162
|
-
|
|
163
|
-
await wrapper.setProps({ modelValue: true });
|
|
164
|
-
|
|
165
|
-
expect(wrapper.vm.internalValue).toBe(true);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
// Test value prop
|
|
170
|
-
describe('Value Prop', () => {
|
|
171
|
-
it('uses default value of true', () => {
|
|
172
|
-
const wrapper = mount(TickBox, {
|
|
173
|
-
props: {
|
|
174
|
-
label: 'Default Value Test',
|
|
175
|
-
modelValue: false
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
expect(wrapper.vm.value).toBe(true);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('accepts string value', () => {
|
|
183
|
-
const wrapper = mount(TickBox, {
|
|
184
|
-
props: {
|
|
185
|
-
label: 'String Value Test',
|
|
186
|
-
modelValue: false,
|
|
187
|
-
value: 'option1'
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
expect(wrapper.vm.value).toBe('option1');
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('accepts number value', () => {
|
|
195
|
-
const wrapper = mount(TickBox, {
|
|
196
|
-
props: {
|
|
197
|
-
label: 'Number Value Test',
|
|
198
|
-
modelValue: false,
|
|
199
|
-
value: 42
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
expect(wrapper.vm.value).toBe(42);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('accepts boolean value', () => {
|
|
207
|
-
const wrapper = mount(TickBox, {
|
|
208
|
-
props: {
|
|
209
|
-
label: 'Boolean Value Test',
|
|
210
|
-
modelValue: false,
|
|
211
|
-
value: false
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
expect(wrapper.vm.value).toBe(false);
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
// Test state props
|
|
220
|
-
describe('State Props', () => {
|
|
221
|
-
it('handles success state', () => {
|
|
222
|
-
const wrapper = mount(TickBox, {
|
|
223
|
-
props: {
|
|
224
|
-
label: 'Success Test',
|
|
225
|
-
modelValue: false,
|
|
226
|
-
success: true
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
expect(wrapper.vm.success).toBe(true);
|
|
231
|
-
expect(wrapper.vm.error).toBe(false);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('handles error state', () => {
|
|
235
|
-
const wrapper = mount(TickBox, {
|
|
236
|
-
props: {
|
|
237
|
-
label: 'Error Test',
|
|
238
|
-
modelValue: false,
|
|
239
|
-
error: true
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
expect(wrapper.vm.error).toBe(true);
|
|
244
|
-
expect(wrapper.vm.success).toBe(false);
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it('handles disabled state', () => {
|
|
248
|
-
const wrapper = mount(TickBox, {
|
|
249
|
-
props: {
|
|
250
|
-
label: 'Disabled Test',
|
|
251
|
-
modelValue: false,
|
|
252
|
-
disabled: true
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
expect(wrapper.vm.disabled).toBe(true);
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
it('handles multiple states together', () => {
|
|
260
|
-
const wrapper = mount(TickBox, {
|
|
261
|
-
props: {
|
|
262
|
-
label: 'Multiple States Test',
|
|
263
|
-
modelValue: false,
|
|
264
|
-
success: true,
|
|
265
|
-
disabled: true
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
expect(wrapper.vm.success).toBe(true);
|
|
270
|
-
expect(wrapper.vm.disabled).toBe(true);
|
|
271
|
-
expect(wrapper.vm.error).toBe(false);
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
it('handles conflicting error and success states', () => {
|
|
275
|
-
const wrapper = mount(TickBox, {
|
|
276
|
-
props: {
|
|
277
|
-
label: 'Conflicting States Test',
|
|
278
|
-
modelValue: false,
|
|
279
|
-
success: true,
|
|
280
|
-
error: true
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
expect(wrapper.vm.success).toBe(true);
|
|
285
|
-
expect(wrapper.vm.error).toBe(true);
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
// Test density prop
|
|
290
|
-
describe('Density', () => {
|
|
291
|
-
it('uses default density of comfortable', () => {
|
|
292
|
-
const wrapper = mount(TickBox, {
|
|
293
|
-
props: {
|
|
294
|
-
label: 'Default Density Test',
|
|
295
|
-
modelValue: false
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
expect(wrapper.vm.density).toBe('comfortable');
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it('accepts custom density', () => {
|
|
303
|
-
const wrapper = mount(TickBox, {
|
|
304
|
-
props: {
|
|
305
|
-
label: 'Custom Density Test',
|
|
306
|
-
modelValue: false,
|
|
307
|
-
density: 'compact'
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
expect(wrapper.vm.density).toBe('compact');
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
it('accepts all density variations', () => {
|
|
315
|
-
const densities = ['comfortable', 'compact', 'default'];
|
|
316
|
-
|
|
317
|
-
densities.forEach(density => {
|
|
318
|
-
const wrapper = mount(TickBox, {
|
|
319
|
-
props: {
|
|
320
|
-
label: `Density ${density} Test`,
|
|
321
|
-
modelValue: false,
|
|
322
|
-
density
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
expect(wrapper.vm.density).toBe(density);
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
// Test computed properties
|
|
332
|
-
describe('Computed Properties', () => {
|
|
333
|
-
describe('checkboxClass', () => {
|
|
334
|
-
it('returns default-state by default', () => {
|
|
335
|
-
const wrapper = mount(TickBox, {
|
|
336
|
-
props: {
|
|
337
|
-
label: 'Default Class Test',
|
|
338
|
-
modelValue: false
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
expect(wrapper.vm.checkboxClass).toBe('default-state');
|
|
343
|
-
expect(wrapper.find('.default-state').exists()).toBe(true);
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
it('returns error-state when error is true', () => {
|
|
347
|
-
const wrapper = mount(TickBox, {
|
|
348
|
-
props: {
|
|
349
|
-
label: 'Error Class Test',
|
|
350
|
-
modelValue: false,
|
|
351
|
-
error: true
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
expect(wrapper.vm.checkboxClass).toBe('error-state');
|
|
356
|
-
expect(wrapper.find('.error-state').exists()).toBe(true);
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
it('returns success-state when success is true', () => {
|
|
360
|
-
const wrapper = mount(TickBox, {
|
|
361
|
-
props: {
|
|
362
|
-
label: 'Success Class Test',
|
|
363
|
-
modelValue: false,
|
|
364
|
-
success: true
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
expect(wrapper.vm.checkboxClass).toBe('success-state');
|
|
369
|
-
expect(wrapper.find('.success-state').exists()).toBe(true);
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
it('prioritizes error over success', () => {
|
|
373
|
-
const wrapper = mount(TickBox, {
|
|
374
|
-
props: {
|
|
375
|
-
label: 'Priority Test',
|
|
376
|
-
modelValue: false,
|
|
377
|
-
success: true,
|
|
378
|
-
error: true
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
expect(wrapper.vm.checkboxClass).toBe('error-state');
|
|
383
|
-
expect(wrapper.find('.error-state').exists()).toBe(true);
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
describe('labelStyles', () => {
|
|
388
|
-
it('returns default color', () => {
|
|
389
|
-
const wrapper = mount(TickBox, {
|
|
390
|
-
props: {
|
|
391
|
-
label: 'Default Style Test',
|
|
392
|
-
modelValue: false
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
expect(wrapper.vm.labelStyles).toEqual({ color: 'var(--Dental-Blue-0)' });
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
it('returns error color when error is true', () => {
|
|
400
|
-
const wrapper = mount(TickBox, {
|
|
401
|
-
props: {
|
|
402
|
-
label: 'Error Style Test',
|
|
403
|
-
modelValue: false,
|
|
404
|
-
error: true
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
expect(wrapper.vm.labelStyles).toEqual({ color: 'var(--Error-Red-0)' });
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
it('returns success color when success is true', () => {
|
|
412
|
-
const wrapper = mount(TickBox, {
|
|
413
|
-
props: {
|
|
414
|
-
label: 'Success Style Test',
|
|
415
|
-
modelValue: false,
|
|
416
|
-
success: true
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
expect(wrapper.vm.labelStyles).toEqual({ color: 'var(--Success-Green-1)' });
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
it('prioritizes error color over success color', () => {
|
|
424
|
-
const wrapper = mount(TickBox, {
|
|
425
|
-
props: {
|
|
426
|
-
label: 'Priority Style Test',
|
|
427
|
-
modelValue: false,
|
|
428
|
-
success: true,
|
|
429
|
-
error: true
|
|
430
|
-
}
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
expect(wrapper.vm.labelStyles).toEqual({ color: 'var(--Error-Red-0)' });
|
|
434
|
-
});
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
describe('hoverColor', () => {
|
|
438
|
-
it('returns default color', () => {
|
|
439
|
-
const wrapper = mount(TickBox, {
|
|
440
|
-
props: {
|
|
441
|
-
label: 'Default Hover Test',
|
|
442
|
-
modelValue: false
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
expect(wrapper.vm.hoverColor).toBe('var(--Dental-Blue-0)');
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
it('returns error color when error is true', () => {
|
|
450
|
-
const wrapper = mount(TickBox, {
|
|
451
|
-
props: {
|
|
452
|
-
label: 'Error Hover Test',
|
|
453
|
-
modelValue: false,
|
|
454
|
-
error: true
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
expect(wrapper.vm.hoverColor).toBe('var(--Error-Red-0)');
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
it('returns success color when success is true', () => {
|
|
462
|
-
const wrapper = mount(TickBox, {
|
|
463
|
-
props: {
|
|
464
|
-
label: 'Success Hover Test',
|
|
465
|
-
modelValue: false,
|
|
466
|
-
success: true
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
expect(wrapper.vm.hoverColor).toBe('var(--Success-Green-1)');
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
it('prioritizes error color over success color', () => {
|
|
474
|
-
const wrapper = mount(TickBox, {
|
|
475
|
-
props: {
|
|
476
|
-
label: 'Priority Hover Test',
|
|
477
|
-
modelValue: false,
|
|
478
|
-
success: true,
|
|
479
|
-
error: true
|
|
480
|
-
}
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
expect(wrapper.vm.hoverColor).toBe('var(--Error-Red-0)');
|
|
484
|
-
});
|
|
485
|
-
});
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
// Test label slot
|
|
489
|
-
describe('Label Slot', () => {
|
|
490
|
-
it('renders label with default styles', () => {
|
|
491
|
-
const wrapper = mount(TickBox, {
|
|
492
|
-
props: {
|
|
493
|
-
label: 'Test Label',
|
|
494
|
-
modelValue: false
|
|
495
|
-
}
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
const labelSpan = wrapper.find('span');
|
|
499
|
-
expect(labelSpan.exists()).toBe(true);
|
|
500
|
-
expect(labelSpan.text()).toBe('Test Label');
|
|
501
|
-
});
|
|
502
|
-
|
|
503
|
-
it('applies dynamic styles to label', () => {
|
|
504
|
-
const wrapper = mount(TickBox, {
|
|
505
|
-
props: {
|
|
506
|
-
label: 'Styled Label',
|
|
507
|
-
modelValue: false,
|
|
508
|
-
error: true
|
|
509
|
-
}
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
const labelSpan = wrapper.find('span');
|
|
513
|
-
expect(labelSpan.exists()).toBe(true);
|
|
514
|
-
// The style attribute would be applied by Vue
|
|
515
|
-
expect(labelSpan.text()).toBe('Styled Label');
|
|
516
|
-
});
|
|
517
|
-
|
|
518
|
-
it('handles empty label', () => {
|
|
519
|
-
const wrapper = mount(TickBox, {
|
|
520
|
-
props: {
|
|
521
|
-
label: '',
|
|
522
|
-
modelValue: false
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
const labelSpan = wrapper.find('span');
|
|
527
|
-
expect(labelSpan.exists()).toBe(true);
|
|
528
|
-
expect(labelSpan.text()).toBe('');
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
it('handles long label text', () => {
|
|
532
|
-
const longLabel = 'This is a very long label that might wrap to multiple lines and should be handled gracefully by the component';
|
|
533
|
-
const wrapper = mount(TickBox, {
|
|
534
|
-
props: {
|
|
535
|
-
label: longLabel,
|
|
536
|
-
modelValue: false
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
const labelSpan = wrapper.find('span');
|
|
541
|
-
expect(labelSpan.text()).toBe(longLabel);
|
|
542
|
-
});
|
|
543
|
-
});
|
|
544
|
-
|
|
545
|
-
// Test Vuetify integration
|
|
546
|
-
describe('Vuetify Integration', () => {
|
|
547
|
-
it('passes props to v-checkbox correctly', () => {
|
|
548
|
-
const wrapper = mount(TickBox, {
|
|
549
|
-
props: {
|
|
550
|
-
label: 'Vuetify Test',
|
|
551
|
-
modelValue: true,
|
|
552
|
-
disabled: true,
|
|
553
|
-
value: 'test-value',
|
|
554
|
-
density: 'compact'
|
|
555
|
-
}
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
expect(wrapper.find('[data-testid="root"]').exists()).toBe(true);
|
|
559
|
-
expect(wrapper.vm.disabled).toBe(true);
|
|
560
|
-
expect(wrapper.vm.value).toBe('test-value');
|
|
561
|
-
expect(wrapper.vm.density).toBe('compact');
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
it('uses custom icons', () => {
|
|
565
|
-
const wrapper = mount(TickBox, {
|
|
566
|
-
props: {
|
|
567
|
-
label: 'Icon Test',
|
|
568
|
-
modelValue: false
|
|
569
|
-
}
|
|
570
|
-
});
|
|
571
|
-
|
|
572
|
-
// The component template specifies heroicons for true and false states
|
|
573
|
-
expect(wrapper.find('[data-testid="root"]').exists()).toBe(true);
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
it('applies color and base-color from hoverColor', () => {
|
|
577
|
-
const wrapper = mount(TickBox, {
|
|
578
|
-
props: {
|
|
579
|
-
label: 'Color Test',
|
|
580
|
-
modelValue: false,
|
|
581
|
-
success: true
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
expect(wrapper.vm.hoverColor).toBe('var(--Success-Green-1)');
|
|
586
|
-
});
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
// Test accessibility
|
|
590
|
-
describe('Accessibility', () => {
|
|
591
|
-
it('has data-testid for testing', () => {
|
|
592
|
-
const wrapper = mount(TickBox, {
|
|
593
|
-
props: {
|
|
594
|
-
label: 'Accessibility Test',
|
|
595
|
-
modelValue: false
|
|
596
|
-
}
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
expect(wrapper.find('[data-testid="root"]').exists()).toBe(true);
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
it('provides meaningful label text', () => {
|
|
603
|
-
const wrapper = mount(TickBox, {
|
|
604
|
-
props: {
|
|
605
|
-
label: 'I agree to the terms and conditions',
|
|
606
|
-
modelValue: false
|
|
607
|
-
}
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
expect(wrapper.vm.label).toBe('I agree to the terms and conditions');
|
|
611
|
-
expect(wrapper.find('span').text()).toBe('I agree to the terms and conditions');
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
it('maintains accessibility with disabled state', () => {
|
|
615
|
-
const wrapper = mount(TickBox, {
|
|
616
|
-
props: {
|
|
617
|
-
label: 'Disabled option',
|
|
618
|
-
modelValue: false,
|
|
619
|
-
disabled: true
|
|
620
|
-
}
|
|
621
|
-
});
|
|
622
|
-
|
|
623
|
-
expect(wrapper.vm.disabled).toBe(true);
|
|
624
|
-
expect(wrapper.find('span').text()).toBe('Disabled option');
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
it('provides visual feedback through states', () => {
|
|
628
|
-
const wrapper = mount(TickBox, {
|
|
629
|
-
props: {
|
|
630
|
-
label: 'Visual feedback test',
|
|
631
|
-
modelValue: false,
|
|
632
|
-
error: true
|
|
633
|
-
}
|
|
634
|
-
});
|
|
635
|
-
|
|
636
|
-
expect(wrapper.vm.error).toBe(true);
|
|
637
|
-
expect(wrapper.vm.checkboxClass).toBe('error-state');
|
|
638
|
-
expect(wrapper.vm.labelStyles.color).toBe('var(--Error-Red-0)');
|
|
639
|
-
});
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
// Test edge cases
|
|
643
|
-
describe('Edge Cases', () => {
|
|
644
|
-
it('handles special characters in label', () => {
|
|
645
|
-
const specialLabel = 'Special chars: !@#$%^&*()_+{}|:"<>?`~[]\\;\',./ ñáéíóú';
|
|
646
|
-
const wrapper = mount(TickBox, {
|
|
647
|
-
props: {
|
|
648
|
-
label: specialLabel,
|
|
649
|
-
modelValue: false
|
|
650
|
-
}
|
|
651
|
-
});
|
|
652
|
-
|
|
653
|
-
expect(wrapper.vm.label).toBe(specialLabel);
|
|
654
|
-
expect(wrapper.find('span').text()).toBe(specialLabel);
|
|
655
|
-
});
|
|
656
|
-
|
|
657
|
-
it('handles HTML entities in label', () => {
|
|
658
|
-
const htmlLabel = 'HTML entities: <>&"'';
|
|
659
|
-
const wrapper = mount(TickBox, {
|
|
660
|
-
props: {
|
|
661
|
-
label: htmlLabel,
|
|
662
|
-
modelValue: false
|
|
663
|
-
}
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
expect(wrapper.vm.label).toBe(htmlLabel);
|
|
667
|
-
});
|
|
668
|
-
|
|
669
|
-
it('handles zero as value', () => {
|
|
670
|
-
const wrapper = mount(TickBox, {
|
|
671
|
-
props: {
|
|
672
|
-
label: 'Zero value test',
|
|
673
|
-
modelValue: [0],
|
|
674
|
-
value: 0
|
|
675
|
-
}
|
|
676
|
-
});
|
|
677
|
-
|
|
678
|
-
expect(wrapper.vm.value).toBe(0);
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
it('handles empty string as value', () => {
|
|
682
|
-
const wrapper = mount(TickBox, {
|
|
683
|
-
props: {
|
|
684
|
-
label: 'Empty string value test',
|
|
685
|
-
modelValue: false,
|
|
686
|
-
value: ''
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
expect(wrapper.vm.value).toBe('');
|
|
691
|
-
});
|
|
692
|
-
|
|
693
|
-
it('handles rapid state changes', async () => {
|
|
694
|
-
const wrapper = mount(TickBox, {
|
|
695
|
-
props: {
|
|
696
|
-
label: 'Rapid changes test',
|
|
697
|
-
modelValue: false
|
|
698
|
-
}
|
|
699
|
-
});
|
|
700
|
-
|
|
701
|
-
await wrapper.setProps({ success: true });
|
|
702
|
-
expect(wrapper.vm.checkboxClass).toBe('success-state');
|
|
703
|
-
|
|
704
|
-
await wrapper.setProps({ success: false, error: true });
|
|
705
|
-
expect(wrapper.vm.checkboxClass).toBe('error-state');
|
|
706
|
-
|
|
707
|
-
await wrapper.setProps({ error: false });
|
|
708
|
-
expect(wrapper.vm.checkboxClass).toBe('default-state');
|
|
709
|
-
});
|
|
710
|
-
});
|
|
711
|
-
|
|
712
|
-
// Test complex scenarios
|
|
713
|
-
describe('Complex Scenarios', () => {
|
|
714
|
-
it('works with all props configured', () => {
|
|
715
|
-
const wrapper = mount(TickBox, {
|
|
716
|
-
props: {
|
|
717
|
-
label: 'Complete configuration test',
|
|
718
|
-
modelValue: ['option1', 'option2'],
|
|
719
|
-
value: 'option1',
|
|
720
|
-
success: true,
|
|
721
|
-
disabled: false,
|
|
722
|
-
density: 'compact'
|
|
723
|
-
}
|
|
724
|
-
});
|
|
725
|
-
|
|
726
|
-
expect(wrapper.vm.label).toBe('Complete configuration test');
|
|
727
|
-
expect(wrapper.vm.modelValue).toEqual(['option1', 'option2']);
|
|
728
|
-
expect(wrapper.vm.value).toBe('option1');
|
|
729
|
-
expect(wrapper.vm.success).toBe(true);
|
|
730
|
-
expect(wrapper.vm.disabled).toBe(false);
|
|
731
|
-
expect(wrapper.vm.density).toBe('compact');
|
|
732
|
-
expect(wrapper.vm.checkboxClass).toBe('success-state');
|
|
733
|
-
expect(wrapper.vm.hoverColor).toBe('var(--Success-Green-1)');
|
|
734
|
-
});
|
|
735
|
-
|
|
736
|
-
it('handles state priority correctly in all combinations', () => {
|
|
737
|
-
// Test error takes priority
|
|
738
|
-
const errorPriorityWrapper = mount(TickBox, {
|
|
739
|
-
props: {
|
|
740
|
-
label: 'Priority test',
|
|
741
|
-
modelValue: false,
|
|
742
|
-
success: true,
|
|
743
|
-
error: true
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
|
|
747
|
-
expect(errorPriorityWrapper.vm.checkboxClass).toBe('error-state');
|
|
748
|
-
expect(errorPriorityWrapper.vm.hoverColor).toBe('var(--Error-Red-0)');
|
|
749
|
-
expect(errorPriorityWrapper.vm.labelStyles.color).toBe('var(--Error-Red-0)');
|
|
750
|
-
});
|
|
751
|
-
|
|
752
|
-
it('maintains reactive updates across all computed properties', async () => {
|
|
753
|
-
const wrapper = mount(TickBox, {
|
|
754
|
-
props: {
|
|
755
|
-
label: 'Reactive test',
|
|
756
|
-
modelValue: false
|
|
757
|
-
}
|
|
758
|
-
});
|
|
759
|
-
|
|
760
|
-
// Initial state
|
|
761
|
-
expect(wrapper.vm.checkboxClass).toBe('default-state');
|
|
762
|
-
expect(wrapper.vm.hoverColor).toBe('var(--Dental-Blue-0)');
|
|
763
|
-
|
|
764
|
-
// Change to success
|
|
765
|
-
await wrapper.setProps({ success: true });
|
|
766
|
-
expect(wrapper.vm.checkboxClass).toBe('success-state');
|
|
767
|
-
expect(wrapper.vm.hoverColor).toBe('var(--Success-Green-1)');
|
|
768
|
-
|
|
769
|
-
// Change to error (should override success)
|
|
770
|
-
await wrapper.setProps({ error: true });
|
|
771
|
-
expect(wrapper.vm.checkboxClass).toBe('error-state');
|
|
772
|
-
expect(wrapper.vm.hoverColor).toBe('var(--Error-Red-0)');
|
|
773
|
-
|
|
774
|
-
// Remove error but keep success
|
|
775
|
-
await wrapper.setProps({ error: false });
|
|
776
|
-
expect(wrapper.vm.checkboxClass).toBe('success-state');
|
|
777
|
-
expect(wrapper.vm.hoverColor).toBe('var(--Success-Green-1)');
|
|
778
|
-
});
|
|
779
|
-
});
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { mount } from '@vue/test-utils';
|
|
3
|
+
import TickBox from '@components/TickBox/TickBox.vue';
|
|
4
|
+
|
|
5
|
+
describe('TickBox', () => {
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
vi.clearAllMocks();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// Test default behavior and rendering
|
|
11
|
+
describe('Default Behavior', () => {
|
|
12
|
+
it('renders with required props', () => {
|
|
13
|
+
const wrapper = mount(TickBox, {
|
|
14
|
+
props: {
|
|
15
|
+
label: 'Test Label',
|
|
16
|
+
modelValue: false
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
expect(wrapper.find('[data-testid="root"]').exists()).toBe(true);
|
|
21
|
+
expect(wrapper.find('.tick-box').exists()).toBe(true);
|
|
22
|
+
expect(wrapper.vm.label).toBe('Test Label');
|
|
23
|
+
expect(wrapper.vm.modelValue).toBe(false);
|
|
24
|
+
expect(wrapper.vm.success).toBe(false);
|
|
25
|
+
expect(wrapper.vm.error).toBe(false);
|
|
26
|
+
expect(wrapper.vm.disabled).toBe(false);
|
|
27
|
+
expect(wrapper.vm.value).toBe(true);
|
|
28
|
+
expect(wrapper.vm.density).toBe('comfortable');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('has data-testid for testing', () => {
|
|
32
|
+
const wrapper = mount(TickBox, {
|
|
33
|
+
props: {
|
|
34
|
+
label: 'Test',
|
|
35
|
+
modelValue: false
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
expect(wrapper.find('[data-testid="root"]').exists()).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('applies tick-box CSS class', () => {
|
|
43
|
+
const wrapper = mount(TickBox, {
|
|
44
|
+
props: {
|
|
45
|
+
label: 'Test',
|
|
46
|
+
modelValue: false
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
expect(wrapper.find('.tick-box').exists()).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('requires label prop', () => {
|
|
54
|
+
// This test verifies that label is marked as required
|
|
55
|
+
const wrapper = mount(TickBox, {
|
|
56
|
+
props: {
|
|
57
|
+
label: 'Required Label',
|
|
58
|
+
modelValue: false
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
expect(wrapper.vm.label).toBe('Required Label');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('requires modelValue prop', () => {
|
|
66
|
+
// This test verifies that modelValue is marked as required
|
|
67
|
+
const wrapper = mount(TickBox, {
|
|
68
|
+
props: {
|
|
69
|
+
label: 'Test',
|
|
70
|
+
modelValue: true
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
expect(wrapper.vm.modelValue).toBe(true);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Test v-model functionality
|
|
79
|
+
describe('v-model', () => {
|
|
80
|
+
it('handles boolean modelValue', () => {
|
|
81
|
+
const wrapper = mount(TickBox, {
|
|
82
|
+
props: {
|
|
83
|
+
label: 'Boolean Test',
|
|
84
|
+
modelValue: true
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(wrapper.vm.internalValue).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('handles false boolean modelValue', () => {
|
|
92
|
+
const wrapper = mount(TickBox, {
|
|
93
|
+
props: {
|
|
94
|
+
label: 'Boolean Test',
|
|
95
|
+
modelValue: false
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
expect(wrapper.vm.internalValue).toBe(false);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('handles array modelValue', () => {
|
|
103
|
+
const wrapper = mount(TickBox, {
|
|
104
|
+
props: {
|
|
105
|
+
label: 'Array Test',
|
|
106
|
+
modelValue: ['option1', 'option2']
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
expect(wrapper.vm.internalValue).toEqual(['option1', 'option2']);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('handles empty array modelValue', () => {
|
|
114
|
+
const wrapper = mount(TickBox, {
|
|
115
|
+
props: {
|
|
116
|
+
label: 'Empty Array Test',
|
|
117
|
+
modelValue: []
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
expect(wrapper.vm.internalValue).toEqual([]);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('emits update:modelValue when internalValue changes', () => {
|
|
125
|
+
const wrapper = mount(TickBox, {
|
|
126
|
+
props: {
|
|
127
|
+
label: 'Emit Test',
|
|
128
|
+
modelValue: false
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
wrapper.vm.internalValue = true;
|
|
133
|
+
|
|
134
|
+
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
|
135
|
+
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([true]);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('updates when modelValue prop changes', async () => {
|
|
139
|
+
const wrapper = mount(TickBox, {
|
|
140
|
+
props: {
|
|
141
|
+
label: 'Update Test',
|
|
142
|
+
modelValue: false
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
expect(wrapper.vm.internalValue).toBe(false);
|
|
147
|
+
|
|
148
|
+
await wrapper.setProps({ modelValue: true });
|
|
149
|
+
|
|
150
|
+
expect(wrapper.vm.internalValue).toBe(true);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('handles array to boolean modelValue changes', async () => {
|
|
154
|
+
const wrapper = mount(TickBox, {
|
|
155
|
+
props: {
|
|
156
|
+
label: 'Type Change Test',
|
|
157
|
+
modelValue: []
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
expect(wrapper.vm.internalValue).toEqual([]);
|
|
162
|
+
|
|
163
|
+
await wrapper.setProps({ modelValue: true });
|
|
164
|
+
|
|
165
|
+
expect(wrapper.vm.internalValue).toBe(true);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Test value prop
|
|
170
|
+
describe('Value Prop', () => {
|
|
171
|
+
it('uses default value of true', () => {
|
|
172
|
+
const wrapper = mount(TickBox, {
|
|
173
|
+
props: {
|
|
174
|
+
label: 'Default Value Test',
|
|
175
|
+
modelValue: false
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
expect(wrapper.vm.value).toBe(true);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('accepts string value', () => {
|
|
183
|
+
const wrapper = mount(TickBox, {
|
|
184
|
+
props: {
|
|
185
|
+
label: 'String Value Test',
|
|
186
|
+
modelValue: false,
|
|
187
|
+
value: 'option1'
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
expect(wrapper.vm.value).toBe('option1');
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('accepts number value', () => {
|
|
195
|
+
const wrapper = mount(TickBox, {
|
|
196
|
+
props: {
|
|
197
|
+
label: 'Number Value Test',
|
|
198
|
+
modelValue: false,
|
|
199
|
+
value: 42
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
expect(wrapper.vm.value).toBe(42);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('accepts boolean value', () => {
|
|
207
|
+
const wrapper = mount(TickBox, {
|
|
208
|
+
props: {
|
|
209
|
+
label: 'Boolean Value Test',
|
|
210
|
+
modelValue: false,
|
|
211
|
+
value: false
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
expect(wrapper.vm.value).toBe(false);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Test state props
|
|
220
|
+
describe('State Props', () => {
|
|
221
|
+
it('handles success state', () => {
|
|
222
|
+
const wrapper = mount(TickBox, {
|
|
223
|
+
props: {
|
|
224
|
+
label: 'Success Test',
|
|
225
|
+
modelValue: false,
|
|
226
|
+
success: true
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
expect(wrapper.vm.success).toBe(true);
|
|
231
|
+
expect(wrapper.vm.error).toBe(false);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('handles error state', () => {
|
|
235
|
+
const wrapper = mount(TickBox, {
|
|
236
|
+
props: {
|
|
237
|
+
label: 'Error Test',
|
|
238
|
+
modelValue: false,
|
|
239
|
+
error: true
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
expect(wrapper.vm.error).toBe(true);
|
|
244
|
+
expect(wrapper.vm.success).toBe(false);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('handles disabled state', () => {
|
|
248
|
+
const wrapper = mount(TickBox, {
|
|
249
|
+
props: {
|
|
250
|
+
label: 'Disabled Test',
|
|
251
|
+
modelValue: false,
|
|
252
|
+
disabled: true
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
expect(wrapper.vm.disabled).toBe(true);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('handles multiple states together', () => {
|
|
260
|
+
const wrapper = mount(TickBox, {
|
|
261
|
+
props: {
|
|
262
|
+
label: 'Multiple States Test',
|
|
263
|
+
modelValue: false,
|
|
264
|
+
success: true,
|
|
265
|
+
disabled: true
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
expect(wrapper.vm.success).toBe(true);
|
|
270
|
+
expect(wrapper.vm.disabled).toBe(true);
|
|
271
|
+
expect(wrapper.vm.error).toBe(false);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('handles conflicting error and success states', () => {
|
|
275
|
+
const wrapper = mount(TickBox, {
|
|
276
|
+
props: {
|
|
277
|
+
label: 'Conflicting States Test',
|
|
278
|
+
modelValue: false,
|
|
279
|
+
success: true,
|
|
280
|
+
error: true
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
expect(wrapper.vm.success).toBe(true);
|
|
285
|
+
expect(wrapper.vm.error).toBe(true);
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// Test density prop
|
|
290
|
+
describe('Density', () => {
|
|
291
|
+
it('uses default density of comfortable', () => {
|
|
292
|
+
const wrapper = mount(TickBox, {
|
|
293
|
+
props: {
|
|
294
|
+
label: 'Default Density Test',
|
|
295
|
+
modelValue: false
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
expect(wrapper.vm.density).toBe('comfortable');
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it('accepts custom density', () => {
|
|
303
|
+
const wrapper = mount(TickBox, {
|
|
304
|
+
props: {
|
|
305
|
+
label: 'Custom Density Test',
|
|
306
|
+
modelValue: false,
|
|
307
|
+
density: 'compact'
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
expect(wrapper.vm.density).toBe('compact');
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
it('accepts all density variations', () => {
|
|
315
|
+
const densities = ['comfortable', 'compact', 'default'];
|
|
316
|
+
|
|
317
|
+
densities.forEach(density => {
|
|
318
|
+
const wrapper = mount(TickBox, {
|
|
319
|
+
props: {
|
|
320
|
+
label: `Density ${density} Test`,
|
|
321
|
+
modelValue: false,
|
|
322
|
+
density
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
expect(wrapper.vm.density).toBe(density);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
// Test computed properties
|
|
332
|
+
describe('Computed Properties', () => {
|
|
333
|
+
describe('checkboxClass', () => {
|
|
334
|
+
it('returns default-state by default', () => {
|
|
335
|
+
const wrapper = mount(TickBox, {
|
|
336
|
+
props: {
|
|
337
|
+
label: 'Default Class Test',
|
|
338
|
+
modelValue: false
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
expect(wrapper.vm.checkboxClass).toBe('default-state');
|
|
343
|
+
expect(wrapper.find('.default-state').exists()).toBe(true);
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
it('returns error-state when error is true', () => {
|
|
347
|
+
const wrapper = mount(TickBox, {
|
|
348
|
+
props: {
|
|
349
|
+
label: 'Error Class Test',
|
|
350
|
+
modelValue: false,
|
|
351
|
+
error: true
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
expect(wrapper.vm.checkboxClass).toBe('error-state');
|
|
356
|
+
expect(wrapper.find('.error-state').exists()).toBe(true);
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it('returns success-state when success is true', () => {
|
|
360
|
+
const wrapper = mount(TickBox, {
|
|
361
|
+
props: {
|
|
362
|
+
label: 'Success Class Test',
|
|
363
|
+
modelValue: false,
|
|
364
|
+
success: true
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
expect(wrapper.vm.checkboxClass).toBe('success-state');
|
|
369
|
+
expect(wrapper.find('.success-state').exists()).toBe(true);
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it('prioritizes error over success', () => {
|
|
373
|
+
const wrapper = mount(TickBox, {
|
|
374
|
+
props: {
|
|
375
|
+
label: 'Priority Test',
|
|
376
|
+
modelValue: false,
|
|
377
|
+
success: true,
|
|
378
|
+
error: true
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
expect(wrapper.vm.checkboxClass).toBe('error-state');
|
|
383
|
+
expect(wrapper.find('.error-state').exists()).toBe(true);
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
describe('labelStyles', () => {
|
|
388
|
+
it('returns default color', () => {
|
|
389
|
+
const wrapper = mount(TickBox, {
|
|
390
|
+
props: {
|
|
391
|
+
label: 'Default Style Test',
|
|
392
|
+
modelValue: false
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
expect(wrapper.vm.labelStyles).toEqual({ color: 'var(--Dental-Blue-0)' });
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it('returns error color when error is true', () => {
|
|
400
|
+
const wrapper = mount(TickBox, {
|
|
401
|
+
props: {
|
|
402
|
+
label: 'Error Style Test',
|
|
403
|
+
modelValue: false,
|
|
404
|
+
error: true
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
expect(wrapper.vm.labelStyles).toEqual({ color: 'var(--Error-Red-0)' });
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
it('returns success color when success is true', () => {
|
|
412
|
+
const wrapper = mount(TickBox, {
|
|
413
|
+
props: {
|
|
414
|
+
label: 'Success Style Test',
|
|
415
|
+
modelValue: false,
|
|
416
|
+
success: true
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
expect(wrapper.vm.labelStyles).toEqual({ color: 'var(--Success-Green-1)' });
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
it('prioritizes error color over success color', () => {
|
|
424
|
+
const wrapper = mount(TickBox, {
|
|
425
|
+
props: {
|
|
426
|
+
label: 'Priority Style Test',
|
|
427
|
+
modelValue: false,
|
|
428
|
+
success: true,
|
|
429
|
+
error: true
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
expect(wrapper.vm.labelStyles).toEqual({ color: 'var(--Error-Red-0)' });
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
describe('hoverColor', () => {
|
|
438
|
+
it('returns default color', () => {
|
|
439
|
+
const wrapper = mount(TickBox, {
|
|
440
|
+
props: {
|
|
441
|
+
label: 'Default Hover Test',
|
|
442
|
+
modelValue: false
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
expect(wrapper.vm.hoverColor).toBe('var(--Dental-Blue-0)');
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
it('returns error color when error is true', () => {
|
|
450
|
+
const wrapper = mount(TickBox, {
|
|
451
|
+
props: {
|
|
452
|
+
label: 'Error Hover Test',
|
|
453
|
+
modelValue: false,
|
|
454
|
+
error: true
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
expect(wrapper.vm.hoverColor).toBe('var(--Error-Red-0)');
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
it('returns success color when success is true', () => {
|
|
462
|
+
const wrapper = mount(TickBox, {
|
|
463
|
+
props: {
|
|
464
|
+
label: 'Success Hover Test',
|
|
465
|
+
modelValue: false,
|
|
466
|
+
success: true
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
expect(wrapper.vm.hoverColor).toBe('var(--Success-Green-1)');
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
it('prioritizes error color over success color', () => {
|
|
474
|
+
const wrapper = mount(TickBox, {
|
|
475
|
+
props: {
|
|
476
|
+
label: 'Priority Hover Test',
|
|
477
|
+
modelValue: false,
|
|
478
|
+
success: true,
|
|
479
|
+
error: true
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
expect(wrapper.vm.hoverColor).toBe('var(--Error-Red-0)');
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
// Test label slot
|
|
489
|
+
describe('Label Slot', () => {
|
|
490
|
+
it('renders label with default styles', () => {
|
|
491
|
+
const wrapper = mount(TickBox, {
|
|
492
|
+
props: {
|
|
493
|
+
label: 'Test Label',
|
|
494
|
+
modelValue: false
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
const labelSpan = wrapper.find('span');
|
|
499
|
+
expect(labelSpan.exists()).toBe(true);
|
|
500
|
+
expect(labelSpan.text()).toBe('Test Label');
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
it('applies dynamic styles to label', () => {
|
|
504
|
+
const wrapper = mount(TickBox, {
|
|
505
|
+
props: {
|
|
506
|
+
label: 'Styled Label',
|
|
507
|
+
modelValue: false,
|
|
508
|
+
error: true
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
const labelSpan = wrapper.find('span');
|
|
513
|
+
expect(labelSpan.exists()).toBe(true);
|
|
514
|
+
// The style attribute would be applied by Vue
|
|
515
|
+
expect(labelSpan.text()).toBe('Styled Label');
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
it('handles empty label', () => {
|
|
519
|
+
const wrapper = mount(TickBox, {
|
|
520
|
+
props: {
|
|
521
|
+
label: '',
|
|
522
|
+
modelValue: false
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
const labelSpan = wrapper.find('span');
|
|
527
|
+
expect(labelSpan.exists()).toBe(true);
|
|
528
|
+
expect(labelSpan.text()).toBe('');
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
it('handles long label text', () => {
|
|
532
|
+
const longLabel = 'This is a very long label that might wrap to multiple lines and should be handled gracefully by the component';
|
|
533
|
+
const wrapper = mount(TickBox, {
|
|
534
|
+
props: {
|
|
535
|
+
label: longLabel,
|
|
536
|
+
modelValue: false
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
const labelSpan = wrapper.find('span');
|
|
541
|
+
expect(labelSpan.text()).toBe(longLabel);
|
|
542
|
+
});
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
// Test Vuetify integration
|
|
546
|
+
describe('Vuetify Integration', () => {
|
|
547
|
+
it('passes props to v-checkbox correctly', () => {
|
|
548
|
+
const wrapper = mount(TickBox, {
|
|
549
|
+
props: {
|
|
550
|
+
label: 'Vuetify Test',
|
|
551
|
+
modelValue: true,
|
|
552
|
+
disabled: true,
|
|
553
|
+
value: 'test-value',
|
|
554
|
+
density: 'compact'
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
expect(wrapper.find('[data-testid="root"]').exists()).toBe(true);
|
|
559
|
+
expect(wrapper.vm.disabled).toBe(true);
|
|
560
|
+
expect(wrapper.vm.value).toBe('test-value');
|
|
561
|
+
expect(wrapper.vm.density).toBe('compact');
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
it('uses custom icons', () => {
|
|
565
|
+
const wrapper = mount(TickBox, {
|
|
566
|
+
props: {
|
|
567
|
+
label: 'Icon Test',
|
|
568
|
+
modelValue: false
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
// The component template specifies heroicons for true and false states
|
|
573
|
+
expect(wrapper.find('[data-testid="root"]').exists()).toBe(true);
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
it('applies color and base-color from hoverColor', () => {
|
|
577
|
+
const wrapper = mount(TickBox, {
|
|
578
|
+
props: {
|
|
579
|
+
label: 'Color Test',
|
|
580
|
+
modelValue: false,
|
|
581
|
+
success: true
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
expect(wrapper.vm.hoverColor).toBe('var(--Success-Green-1)');
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
// Test accessibility
|
|
590
|
+
describe('Accessibility', () => {
|
|
591
|
+
it('has data-testid for testing', () => {
|
|
592
|
+
const wrapper = mount(TickBox, {
|
|
593
|
+
props: {
|
|
594
|
+
label: 'Accessibility Test',
|
|
595
|
+
modelValue: false
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
expect(wrapper.find('[data-testid="root"]').exists()).toBe(true);
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
it('provides meaningful label text', () => {
|
|
603
|
+
const wrapper = mount(TickBox, {
|
|
604
|
+
props: {
|
|
605
|
+
label: 'I agree to the terms and conditions',
|
|
606
|
+
modelValue: false
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
expect(wrapper.vm.label).toBe('I agree to the terms and conditions');
|
|
611
|
+
expect(wrapper.find('span').text()).toBe('I agree to the terms and conditions');
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
it('maintains accessibility with disabled state', () => {
|
|
615
|
+
const wrapper = mount(TickBox, {
|
|
616
|
+
props: {
|
|
617
|
+
label: 'Disabled option',
|
|
618
|
+
modelValue: false,
|
|
619
|
+
disabled: true
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
expect(wrapper.vm.disabled).toBe(true);
|
|
624
|
+
expect(wrapper.find('span').text()).toBe('Disabled option');
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
it('provides visual feedback through states', () => {
|
|
628
|
+
const wrapper = mount(TickBox, {
|
|
629
|
+
props: {
|
|
630
|
+
label: 'Visual feedback test',
|
|
631
|
+
modelValue: false,
|
|
632
|
+
error: true
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
expect(wrapper.vm.error).toBe(true);
|
|
637
|
+
expect(wrapper.vm.checkboxClass).toBe('error-state');
|
|
638
|
+
expect(wrapper.vm.labelStyles.color).toBe('var(--Error-Red-0)');
|
|
639
|
+
});
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
// Test edge cases
|
|
643
|
+
describe('Edge Cases', () => {
|
|
644
|
+
it('handles special characters in label', () => {
|
|
645
|
+
const specialLabel = 'Special chars: !@#$%^&*()_+{}|:"<>?`~[]\\;\',./ ñáéíóú';
|
|
646
|
+
const wrapper = mount(TickBox, {
|
|
647
|
+
props: {
|
|
648
|
+
label: specialLabel,
|
|
649
|
+
modelValue: false
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
expect(wrapper.vm.label).toBe(specialLabel);
|
|
654
|
+
expect(wrapper.find('span').text()).toBe(specialLabel);
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
it('handles HTML entities in label', () => {
|
|
658
|
+
const htmlLabel = 'HTML entities: <>&"'';
|
|
659
|
+
const wrapper = mount(TickBox, {
|
|
660
|
+
props: {
|
|
661
|
+
label: htmlLabel,
|
|
662
|
+
modelValue: false
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
expect(wrapper.vm.label).toBe(htmlLabel);
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
it('handles zero as value', () => {
|
|
670
|
+
const wrapper = mount(TickBox, {
|
|
671
|
+
props: {
|
|
672
|
+
label: 'Zero value test',
|
|
673
|
+
modelValue: [0],
|
|
674
|
+
value: 0
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
expect(wrapper.vm.value).toBe(0);
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
it('handles empty string as value', () => {
|
|
682
|
+
const wrapper = mount(TickBox, {
|
|
683
|
+
props: {
|
|
684
|
+
label: 'Empty string value test',
|
|
685
|
+
modelValue: false,
|
|
686
|
+
value: ''
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
expect(wrapper.vm.value).toBe('');
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
it('handles rapid state changes', async () => {
|
|
694
|
+
const wrapper = mount(TickBox, {
|
|
695
|
+
props: {
|
|
696
|
+
label: 'Rapid changes test',
|
|
697
|
+
modelValue: false
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
|
|
701
|
+
await wrapper.setProps({ success: true });
|
|
702
|
+
expect(wrapper.vm.checkboxClass).toBe('success-state');
|
|
703
|
+
|
|
704
|
+
await wrapper.setProps({ success: false, error: true });
|
|
705
|
+
expect(wrapper.vm.checkboxClass).toBe('error-state');
|
|
706
|
+
|
|
707
|
+
await wrapper.setProps({ error: false });
|
|
708
|
+
expect(wrapper.vm.checkboxClass).toBe('default-state');
|
|
709
|
+
});
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
// Test complex scenarios
|
|
713
|
+
describe('Complex Scenarios', () => {
|
|
714
|
+
it('works with all props configured', () => {
|
|
715
|
+
const wrapper = mount(TickBox, {
|
|
716
|
+
props: {
|
|
717
|
+
label: 'Complete configuration test',
|
|
718
|
+
modelValue: ['option1', 'option2'],
|
|
719
|
+
value: 'option1',
|
|
720
|
+
success: true,
|
|
721
|
+
disabled: false,
|
|
722
|
+
density: 'compact'
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
expect(wrapper.vm.label).toBe('Complete configuration test');
|
|
727
|
+
expect(wrapper.vm.modelValue).toEqual(['option1', 'option2']);
|
|
728
|
+
expect(wrapper.vm.value).toBe('option1');
|
|
729
|
+
expect(wrapper.vm.success).toBe(true);
|
|
730
|
+
expect(wrapper.vm.disabled).toBe(false);
|
|
731
|
+
expect(wrapper.vm.density).toBe('compact');
|
|
732
|
+
expect(wrapper.vm.checkboxClass).toBe('success-state');
|
|
733
|
+
expect(wrapper.vm.hoverColor).toBe('var(--Success-Green-1)');
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
it('handles state priority correctly in all combinations', () => {
|
|
737
|
+
// Test error takes priority
|
|
738
|
+
const errorPriorityWrapper = mount(TickBox, {
|
|
739
|
+
props: {
|
|
740
|
+
label: 'Priority test',
|
|
741
|
+
modelValue: false,
|
|
742
|
+
success: true,
|
|
743
|
+
error: true
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
expect(errorPriorityWrapper.vm.checkboxClass).toBe('error-state');
|
|
748
|
+
expect(errorPriorityWrapper.vm.hoverColor).toBe('var(--Error-Red-0)');
|
|
749
|
+
expect(errorPriorityWrapper.vm.labelStyles.color).toBe('var(--Error-Red-0)');
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
it('maintains reactive updates across all computed properties', async () => {
|
|
753
|
+
const wrapper = mount(TickBox, {
|
|
754
|
+
props: {
|
|
755
|
+
label: 'Reactive test',
|
|
756
|
+
modelValue: false
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
|
|
760
|
+
// Initial state
|
|
761
|
+
expect(wrapper.vm.checkboxClass).toBe('default-state');
|
|
762
|
+
expect(wrapper.vm.hoverColor).toBe('var(--Dental-Blue-0)');
|
|
763
|
+
|
|
764
|
+
// Change to success
|
|
765
|
+
await wrapper.setProps({ success: true });
|
|
766
|
+
expect(wrapper.vm.checkboxClass).toBe('success-state');
|
|
767
|
+
expect(wrapper.vm.hoverColor).toBe('var(--Success-Green-1)');
|
|
768
|
+
|
|
769
|
+
// Change to error (should override success)
|
|
770
|
+
await wrapper.setProps({ error: true });
|
|
771
|
+
expect(wrapper.vm.checkboxClass).toBe('error-state');
|
|
772
|
+
expect(wrapper.vm.hoverColor).toBe('var(--Error-Red-0)');
|
|
773
|
+
|
|
774
|
+
// Remove error but keep success
|
|
775
|
+
await wrapper.setProps({ error: false });
|
|
776
|
+
expect(wrapper.vm.checkboxClass).toBe('success-state');
|
|
777
|
+
expect(wrapper.vm.hoverColor).toBe('var(--Success-Green-1)');
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
780
|
});
|