@getmicdrop/svelte-components 2.0.4 → 2.0.6
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/dist/components/Alert/Alert.spec.js +170 -170
- package/dist/components/Badges/Badge.spec.js +103 -103
- package/dist/components/BottomSheet/BottomSheet.spec.js +127 -127
- package/dist/components/Breadcrumb/Breadcrumb.spec.js +120 -120
- package/dist/components/Button/Button.spec.js +211 -211
- package/dist/components/Button/ButtonSaveDemo.spec.js +48 -48
- package/dist/components/Calendar/Calendar.spec.js +131 -131
- package/dist/components/Calendar/QuarterView.spec.js +394 -394
- package/dist/components/Card.spec.js +47 -47
- package/dist/components/CropImage/CropImage.spec.js +216 -216
- package/dist/components/DarkModeToggle.spec.js +357 -357
- package/dist/components/ErrorDisplay.spec.js +69 -69
- package/dist/components/FormActions.spec.js +88 -88
- package/dist/components/FormValidationSummary.spec.js +203 -203
- package/dist/components/Icons/Icon.spec.js +175 -175
- package/dist/components/Icons/MoreHori.spec.js +67 -67
- package/dist/components/Icons/WarningIcon.spec.js +30 -30
- package/dist/components/Input/Input.spec.js +573 -573
- package/dist/components/Input/MultiSelect.spec.js +257 -257
- package/dist/components/Input/OTPInput.spec.js +238 -238
- package/dist/components/Input/Select.spec.js +218 -218
- package/dist/components/Layout/BottomNav.spec.js +130 -130
- package/dist/components/Layout/Header.spec.js +203 -203
- package/dist/components/Modal/ConfirmationModal.spec.js +191 -191
- package/dist/components/Modal/Modal.spec.js +95 -95
- package/dist/components/Modal/ModalStateManager.spec.js +100 -100
- package/dist/components/PageLoader.spec.js +54 -54
- package/dist/components/PasswordStrengthIndicator/PasswordStrengthIndicator.spec.js +173 -173
- package/dist/components/PlaceAutocomplete/PlaceAutocomplete.spec.js +300 -300
- package/dist/components/Spinner/Spinner.spec.js +75 -75
- package/dist/components/StatusIndicator/StatusIndicator.spec.js +129 -129
- package/dist/components/Toaster/Toaster.stories.svelte +1 -1
- package/dist/components/Toggle.spec.js +158 -158
- package/dist/components/ValidationError.spec.js +79 -79
- package/dist/components/pages/performers/AvailabilityCalendarModal.spec.js +606 -606
- package/dist/components/pages/performers/AvailabilityCalendarModal.svelte +4 -4
- package/dist/components/pages/performers/ModalShowInfo.spec.js +124 -124
- package/dist/components/pages/performers/ModalShowInfo.svelte +1 -1
- package/dist/components/pages/performers/PageBackButton.spec.js +89 -89
- package/dist/components/pages/performers/SectionHeader.spec.js +75 -75
- package/dist/components/pages/performers/ShowDetails.spec.js +166 -166
- package/dist/components/pages/performers/ShowItemCard.spec.js +793 -793
- package/dist/components/pages/performers/ShowItemCard.svelte +4 -4
- package/dist/components/pages/performers/SwitchOption.spec.js +127 -127
- package/dist/components/pages/performers/VenueInfo.spec.js +167 -167
- package/dist/components/pages/performers/VenueInfo.svelte +1 -1
- package/dist/components/pages/performers/VenueItemCard.spec.js +763 -763
- package/dist/components/pages/performers/VenueItemCard.svelte +4 -4
- package/dist/components/pages/profile/profile-form.spec.js +9 -9
- package/dist/components/pages/settings/tabs/CustomImageDropzone.svelte +3 -3
- package/dist/components/pages/shows/ShowList.spec.js +33 -33
- package/dist/components/pages/shows/TabContent.spec.js +90 -90
- package/dist/components/pages/shows/TabNavigation.spec.js +143 -143
- package/dist/config.js +5 -5
- package/dist/config.spec.js +29 -29
- package/dist/constants/formOptions.js +25 -25
- package/dist/constants/formOptions.spec.js +88 -88
- package/dist/index.js +111 -111
- package/dist/stores/auth.d.ts +9 -0
- package/dist/stores/auth.d.ts.map +1 -0
- package/dist/stores/auth.js +36 -0
- package/dist/stores/auth.spec.d.ts +2 -0
- package/dist/stores/auth.spec.d.ts.map +1 -0
- package/dist/stores/auth.spec.js +139 -0
- package/dist/stores/formDataStore.d.ts +17 -0
- package/dist/stores/formDataStore.d.ts.map +1 -0
- package/dist/stores/formDataStore.js +25 -0
- package/dist/stores/formDataStore.spec.d.ts +2 -0
- package/dist/stores/formDataStore.spec.d.ts.map +1 -0
- package/dist/stores/formDataStore.spec.js +257 -0
- package/dist/stores/formSave.d.ts +24 -0
- package/dist/stores/formSave.d.ts.map +1 -0
- package/dist/stores/formSave.js +132 -0
- package/dist/stores/formSave.spec.d.ts +2 -0
- package/dist/stores/formSave.spec.d.ts.map +1 -0
- package/dist/stores/formSave.spec.js +296 -0
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/index.js +0 -0
- package/dist/stores/navigation.d.ts +5 -0
- package/dist/stores/navigation.d.ts.map +1 -0
- package/dist/stores/navigation.js +12 -0
- package/dist/stores/navigation.spec.d.ts +2 -0
- package/dist/stores/navigation.spec.d.ts.map +1 -0
- package/dist/stores/navigation.spec.js +136 -0
- package/dist/stores/toaster.d.ts +4 -0
- package/dist/stores/toaster.d.ts.map +1 -0
- package/dist/stores/toaster.js +13 -0
- package/dist/stores/toaster.spec.d.ts +2 -0
- package/dist/stores/toaster.spec.d.ts.map +1 -0
- package/dist/stores/toaster.spec.js +59 -0
- package/dist/telemetry.js +357 -357
- package/dist/telemetry.server.js +211 -211
- package/dist/telemetry.server.spec.js +434 -434
- package/dist/telemetry.spec.js +660 -660
- package/dist/utils/apiConfig.js +49 -49
- package/dist/utils/apiConfig.spec.js +118 -118
- package/dist/utils/greetings.js +187 -187
- package/dist/utils/greetings.spec.js +337 -337
- package/dist/utils/imageValidation.js +121 -121
- package/dist/utils/imageValidation.spec.js +220 -220
- package/dist/utils/portal.js +25 -25
- package/dist/utils/portal.spec.js +143 -143
- package/dist/utils/utils/utils.js +323 -323
- package/dist/utils/utils/utils.spec.js +698 -698
- package/dist/utils/utils.spec.js +643 -643
- package/package.json +1 -1
|
@@ -1,203 +1,203 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { render, fireEvent } from '@testing-library/svelte';
|
|
3
|
-
import FormValidationSummary from './FormValidationSummary.svelte';
|
|
4
|
-
|
|
5
|
-
describe('FormValidationSummary Component', () => {
|
|
6
|
-
it('does not render when show is false', () => {
|
|
7
|
-
const { container } = render(FormValidationSummary, {
|
|
8
|
-
props: {
|
|
9
|
-
show: false,
|
|
10
|
-
errors: { firstName: 'Required' },
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
const alert = container.querySelector('[role="alert"]');
|
|
14
|
-
expect(alert).toBeFalsy();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('does not render when there are no errors', () => {
|
|
18
|
-
const { container } = render(FormValidationSummary, {
|
|
19
|
-
props: {
|
|
20
|
-
show: true,
|
|
21
|
-
errors: {},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
const alert = container.querySelector('[role="alert"]');
|
|
25
|
-
expect(alert).toBeFalsy();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('does not render when errors have empty messages', () => {
|
|
29
|
-
const { container } = render(FormValidationSummary, {
|
|
30
|
-
props: {
|
|
31
|
-
show: true,
|
|
32
|
-
errors: { firstName: '', lastName: ' ' },
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
const alert = container.querySelector('[role="alert"]');
|
|
36
|
-
expect(alert).toBeFalsy();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('renders when show is true and has errors', () => {
|
|
40
|
-
const { container, getByText } = render(FormValidationSummary, {
|
|
41
|
-
props: {
|
|
42
|
-
show: true,
|
|
43
|
-
errors: { firstName: 'First name is required' },
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
const alert = container.querySelector('[role="alert"]');
|
|
47
|
-
expect(alert).toBeTruthy();
|
|
48
|
-
expect(getByText('Please fix the following:')).toBeTruthy();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('displays error field labels', () => {
|
|
52
|
-
const { getByText } = render(FormValidationSummary, {
|
|
53
|
-
props: {
|
|
54
|
-
show: true,
|
|
55
|
-
errors: { firstName: 'Required', email: 'Invalid' },
|
|
56
|
-
fieldLabels: { firstName: 'First Name', email: 'Email Address' },
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
expect(getByText('First Name')).toBeTruthy();
|
|
60
|
-
expect(getByText('Email Address')).toBeTruthy();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('uses field key as label when no label provided', () => {
|
|
64
|
-
const { getByText } = render(FormValidationSummary, {
|
|
65
|
-
props: {
|
|
66
|
-
show: true,
|
|
67
|
-
errors: { firstName: 'Required' },
|
|
68
|
-
fieldLabels: {},
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
expect(getByText('firstName')).toBeTruthy();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('renders multiple error fields', () => {
|
|
75
|
-
const { container } = render(FormValidationSummary, {
|
|
76
|
-
props: {
|
|
77
|
-
show: true,
|
|
78
|
-
errors: {
|
|
79
|
-
firstName: 'Required',
|
|
80
|
-
lastName: 'Required',
|
|
81
|
-
email: 'Invalid format',
|
|
82
|
-
},
|
|
83
|
-
fieldLabels: {
|
|
84
|
-
firstName: 'First Name',
|
|
85
|
-
lastName: 'Last Name',
|
|
86
|
-
email: 'Email',
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
const listItems = container.querySelectorAll('li');
|
|
91
|
-
expect(listItems.length).toBe(3);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('has role="alert" and aria-live="polite"', () => {
|
|
95
|
-
const { container } = render(FormValidationSummary, {
|
|
96
|
-
props: {
|
|
97
|
-
show: true,
|
|
98
|
-
errors: { firstName: 'Required' },
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
const alert = container.querySelector('[role="alert"]');
|
|
102
|
-
expect(alert.getAttribute('aria-live')).toBe('polite');
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('renders clickable buttons for each error', () => {
|
|
106
|
-
const { container } = render(FormValidationSummary, {
|
|
107
|
-
props: {
|
|
108
|
-
show: true,
|
|
109
|
-
errors: { firstName: 'Required', email: 'Invalid' },
|
|
110
|
-
fieldLabels: { firstName: 'First Name', email: 'Email' },
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
const buttons = container.querySelectorAll('button[type="button"]');
|
|
114
|
-
expect(buttons.length).toBe(2);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('calls scrollIntoView on button click', async () => {
|
|
118
|
-
// Create a mock element
|
|
119
|
-
const mockElement = document.createElement('input');
|
|
120
|
-
mockElement.id = 'firstName';
|
|
121
|
-
mockElement.scrollIntoView = vi.fn();
|
|
122
|
-
mockElement.focus = vi.fn();
|
|
123
|
-
document.body.appendChild(mockElement);
|
|
124
|
-
|
|
125
|
-
const { container } = render(FormValidationSummary, {
|
|
126
|
-
props: {
|
|
127
|
-
show: true,
|
|
128
|
-
errors: { firstName: 'Required' },
|
|
129
|
-
fieldLabels: { firstName: 'First Name' },
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
const button = container.querySelector('button[type="button"]');
|
|
134
|
-
await fireEvent.click(button);
|
|
135
|
-
|
|
136
|
-
expect(mockElement.scrollIntoView).toHaveBeenCalledWith({
|
|
137
|
-
behavior: 'smooth',
|
|
138
|
-
block: 'center',
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
// Clean up
|
|
142
|
-
document.body.removeChild(mockElement);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('uses custom fieldIds for scrolling', async () => {
|
|
146
|
-
const mockElement = document.createElement('input');
|
|
147
|
-
mockElement.id = 'custom-first-name-input';
|
|
148
|
-
mockElement.scrollIntoView = vi.fn();
|
|
149
|
-
mockElement.focus = vi.fn();
|
|
150
|
-
document.body.appendChild(mockElement);
|
|
151
|
-
|
|
152
|
-
const { container } = render(FormValidationSummary, {
|
|
153
|
-
props: {
|
|
154
|
-
show: true,
|
|
155
|
-
errors: { firstName: 'Required' },
|
|
156
|
-
fieldLabels: { firstName: 'First Name' },
|
|
157
|
-
fieldIds: { firstName: 'custom-first-name-input' },
|
|
158
|
-
},
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
const button = container.querySelector('button[type="button"]');
|
|
162
|
-
await fireEvent.click(button);
|
|
163
|
-
|
|
164
|
-
expect(mockElement.scrollIntoView).toHaveBeenCalled();
|
|
165
|
-
|
|
166
|
-
document.body.removeChild(mockElement);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('has red background styling', () => {
|
|
170
|
-
const { container } = render(FormValidationSummary, {
|
|
171
|
-
props: {
|
|
172
|
-
show: true,
|
|
173
|
-
errors: { firstName: 'Required' },
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
const alert = container.querySelector('[role="alert"]');
|
|
177
|
-
expect(alert.classList.contains('bg-red-50')).toBe(true);
|
|
178
|
-
expect(alert.classList.contains('border-red-200')).toBe(true);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
it('renders warning icon', () => {
|
|
182
|
-
const { container } = render(FormValidationSummary, {
|
|
183
|
-
props: {
|
|
184
|
-
show: true,
|
|
185
|
-
errors: { firstName: 'Required' },
|
|
186
|
-
},
|
|
187
|
-
});
|
|
188
|
-
const svg = container.querySelector('svg');
|
|
189
|
-
expect(svg).toBeTruthy();
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('filters out null and undefined error values', () => {
|
|
193
|
-
const { container } = render(FormValidationSummary, {
|
|
194
|
-
props: {
|
|
195
|
-
show: true,
|
|
196
|
-
errors: { firstName: 'Required', lastName: null, email: undefined },
|
|
197
|
-
fieldLabels: { firstName: 'First Name', lastName: 'Last Name', email: 'Email' },
|
|
198
|
-
},
|
|
199
|
-
});
|
|
200
|
-
const listItems = container.querySelectorAll('li');
|
|
201
|
-
expect(listItems.length).toBe(1);
|
|
202
|
-
});
|
|
203
|
-
});
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/svelte';
|
|
3
|
+
import FormValidationSummary from './FormValidationSummary.svelte';
|
|
4
|
+
|
|
5
|
+
describe('FormValidationSummary Component', () => {
|
|
6
|
+
it('does not render when show is false', () => {
|
|
7
|
+
const { container } = render(FormValidationSummary, {
|
|
8
|
+
props: {
|
|
9
|
+
show: false,
|
|
10
|
+
errors: { firstName: 'Required' },
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
const alert = container.querySelector('[role="alert"]');
|
|
14
|
+
expect(alert).toBeFalsy();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('does not render when there are no errors', () => {
|
|
18
|
+
const { container } = render(FormValidationSummary, {
|
|
19
|
+
props: {
|
|
20
|
+
show: true,
|
|
21
|
+
errors: {},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const alert = container.querySelector('[role="alert"]');
|
|
25
|
+
expect(alert).toBeFalsy();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('does not render when errors have empty messages', () => {
|
|
29
|
+
const { container } = render(FormValidationSummary, {
|
|
30
|
+
props: {
|
|
31
|
+
show: true,
|
|
32
|
+
errors: { firstName: '', lastName: ' ' },
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const alert = container.querySelector('[role="alert"]');
|
|
36
|
+
expect(alert).toBeFalsy();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('renders when show is true and has errors', () => {
|
|
40
|
+
const { container, getByText } = render(FormValidationSummary, {
|
|
41
|
+
props: {
|
|
42
|
+
show: true,
|
|
43
|
+
errors: { firstName: 'First name is required' },
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const alert = container.querySelector('[role="alert"]');
|
|
47
|
+
expect(alert).toBeTruthy();
|
|
48
|
+
expect(getByText('Please fix the following:')).toBeTruthy();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('displays error field labels', () => {
|
|
52
|
+
const { getByText } = render(FormValidationSummary, {
|
|
53
|
+
props: {
|
|
54
|
+
show: true,
|
|
55
|
+
errors: { firstName: 'Required', email: 'Invalid' },
|
|
56
|
+
fieldLabels: { firstName: 'First Name', email: 'Email Address' },
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
expect(getByText('First Name')).toBeTruthy();
|
|
60
|
+
expect(getByText('Email Address')).toBeTruthy();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('uses field key as label when no label provided', () => {
|
|
64
|
+
const { getByText } = render(FormValidationSummary, {
|
|
65
|
+
props: {
|
|
66
|
+
show: true,
|
|
67
|
+
errors: { firstName: 'Required' },
|
|
68
|
+
fieldLabels: {},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
expect(getByText('firstName')).toBeTruthy();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('renders multiple error fields', () => {
|
|
75
|
+
const { container } = render(FormValidationSummary, {
|
|
76
|
+
props: {
|
|
77
|
+
show: true,
|
|
78
|
+
errors: {
|
|
79
|
+
firstName: 'Required',
|
|
80
|
+
lastName: 'Required',
|
|
81
|
+
email: 'Invalid format',
|
|
82
|
+
},
|
|
83
|
+
fieldLabels: {
|
|
84
|
+
firstName: 'First Name',
|
|
85
|
+
lastName: 'Last Name',
|
|
86
|
+
email: 'Email',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
const listItems = container.querySelectorAll('li');
|
|
91
|
+
expect(listItems.length).toBe(3);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('has role="alert" and aria-live="polite"', () => {
|
|
95
|
+
const { container } = render(FormValidationSummary, {
|
|
96
|
+
props: {
|
|
97
|
+
show: true,
|
|
98
|
+
errors: { firstName: 'Required' },
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
const alert = container.querySelector('[role="alert"]');
|
|
102
|
+
expect(alert.getAttribute('aria-live')).toBe('polite');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('renders clickable buttons for each error', () => {
|
|
106
|
+
const { container } = render(FormValidationSummary, {
|
|
107
|
+
props: {
|
|
108
|
+
show: true,
|
|
109
|
+
errors: { firstName: 'Required', email: 'Invalid' },
|
|
110
|
+
fieldLabels: { firstName: 'First Name', email: 'Email' },
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
const buttons = container.querySelectorAll('button[type="button"]');
|
|
114
|
+
expect(buttons.length).toBe(2);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('calls scrollIntoView on button click', async () => {
|
|
118
|
+
// Create a mock element
|
|
119
|
+
const mockElement = document.createElement('input');
|
|
120
|
+
mockElement.id = 'firstName';
|
|
121
|
+
mockElement.scrollIntoView = vi.fn();
|
|
122
|
+
mockElement.focus = vi.fn();
|
|
123
|
+
document.body.appendChild(mockElement);
|
|
124
|
+
|
|
125
|
+
const { container } = render(FormValidationSummary, {
|
|
126
|
+
props: {
|
|
127
|
+
show: true,
|
|
128
|
+
errors: { firstName: 'Required' },
|
|
129
|
+
fieldLabels: { firstName: 'First Name' },
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const button = container.querySelector('button[type="button"]');
|
|
134
|
+
await fireEvent.click(button);
|
|
135
|
+
|
|
136
|
+
expect(mockElement.scrollIntoView).toHaveBeenCalledWith({
|
|
137
|
+
behavior: 'smooth',
|
|
138
|
+
block: 'center',
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Clean up
|
|
142
|
+
document.body.removeChild(mockElement);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('uses custom fieldIds for scrolling', async () => {
|
|
146
|
+
const mockElement = document.createElement('input');
|
|
147
|
+
mockElement.id = 'custom-first-name-input';
|
|
148
|
+
mockElement.scrollIntoView = vi.fn();
|
|
149
|
+
mockElement.focus = vi.fn();
|
|
150
|
+
document.body.appendChild(mockElement);
|
|
151
|
+
|
|
152
|
+
const { container } = render(FormValidationSummary, {
|
|
153
|
+
props: {
|
|
154
|
+
show: true,
|
|
155
|
+
errors: { firstName: 'Required' },
|
|
156
|
+
fieldLabels: { firstName: 'First Name' },
|
|
157
|
+
fieldIds: { firstName: 'custom-first-name-input' },
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const button = container.querySelector('button[type="button"]');
|
|
162
|
+
await fireEvent.click(button);
|
|
163
|
+
|
|
164
|
+
expect(mockElement.scrollIntoView).toHaveBeenCalled();
|
|
165
|
+
|
|
166
|
+
document.body.removeChild(mockElement);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('has red background styling', () => {
|
|
170
|
+
const { container } = render(FormValidationSummary, {
|
|
171
|
+
props: {
|
|
172
|
+
show: true,
|
|
173
|
+
errors: { firstName: 'Required' },
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
const alert = container.querySelector('[role="alert"]');
|
|
177
|
+
expect(alert.classList.contains('bg-red-50')).toBe(true);
|
|
178
|
+
expect(alert.classList.contains('border-red-200')).toBe(true);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('renders warning icon', () => {
|
|
182
|
+
const { container } = render(FormValidationSummary, {
|
|
183
|
+
props: {
|
|
184
|
+
show: true,
|
|
185
|
+
errors: { firstName: 'Required' },
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
const svg = container.querySelector('svg');
|
|
189
|
+
expect(svg).toBeTruthy();
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('filters out null and undefined error values', () => {
|
|
193
|
+
const { container } = render(FormValidationSummary, {
|
|
194
|
+
props: {
|
|
195
|
+
show: true,
|
|
196
|
+
errors: { firstName: 'Required', lastName: null, email: undefined },
|
|
197
|
+
fieldLabels: { firstName: 'First Name', lastName: 'Last Name', email: 'Email' },
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
const listItems = container.querySelectorAll('li');
|
|
201
|
+
expect(listItems.length).toBe(1);
|
|
202
|
+
});
|
|
203
|
+
});
|