@getmicdrop/svelte-components 5.5.4 → 5.5.5
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/calendar/AboutShow/AboutShow.spec.d.ts +2 -0
- package/dist/calendar/AboutShow/AboutShow.spec.d.ts.map +1 -0
- package/dist/calendar/AboutShow/AboutShow.spec.js +791 -0
- package/dist/calendar/Calendar/MiniMonthCalendar.spec.d.ts +2 -0
- package/dist/calendar/Calendar/MiniMonthCalendar.spec.d.ts.map +1 -0
- package/dist/calendar/Calendar/MiniMonthCalendar.spec.js +1191 -0
- package/dist/calendar/FAQs/FAQs.spec.d.ts +2 -0
- package/dist/calendar/FAQs/FAQs.spec.d.ts.map +1 -0
- package/dist/calendar/FAQs/FAQs.spec.js +238 -0
- package/dist/calendar/MonthSwitcher/MonthSwitcher.spec.d.ts +2 -0
- package/dist/calendar/MonthSwitcher/MonthSwitcher.spec.d.ts.map +1 -0
- package/dist/calendar/MonthSwitcher/MonthSwitcher.spec.js +420 -0
- package/dist/calendar/OrderSummary/OrderSummary.spec.d.ts +2 -0
- package/dist/calendar/OrderSummary/OrderSummary.spec.d.ts.map +1 -0
- package/dist/calendar/OrderSummary/OrderSummary.spec.js +808 -0
- package/dist/calendar/PublicCard/PublicCard.spec.d.ts +2 -0
- package/dist/calendar/PublicCard/PublicCard.spec.d.ts.map +1 -0
- package/dist/calendar/PublicCard/PublicCard.spec.js +301 -0
- package/dist/calendar/ShowCard/ShowCard.spec.d.ts +2 -0
- package/dist/calendar/ShowCard/ShowCard.spec.d.ts.map +1 -0
- package/dist/calendar/ShowCard/ShowCard.spec.js +714 -0
- package/dist/calendar/ShowTimeCard/ShowTimeCard.spec.d.ts +2 -0
- package/dist/calendar/ShowTimeCard/ShowTimeCard.spec.d.ts.map +1 -0
- package/dist/calendar/ShowTimeCard/ShowTimeCard.spec.js +241 -0
- package/dist/components/Layout/Section.spec.d.ts +2 -0
- package/dist/components/Layout/Section.spec.d.ts.map +1 -0
- package/dist/components/Layout/Section.spec.js +149 -0
- package/dist/components/Layout/Sidebar.spec.d.ts +2 -0
- package/dist/components/Layout/Sidebar.spec.d.ts.map +1 -0
- package/dist/components/Layout/Sidebar.spec.js +186 -0
- package/dist/components/Layout/Stack.spec.js +3 -3
- package/dist/constants/formOptions.spec.js +9 -5
- package/dist/datetime/__tests__/format.test.js +1 -1
- package/dist/datetime/__tests__/parse.test.js +1 -1
- package/dist/datetime/__tests__/timezone.test.js +124 -2
- package/dist/datetime/parse.js +1 -1
- package/dist/forms/createFieldTracker.spec.d.ts +2 -0
- package/dist/forms/createFieldTracker.spec.d.ts.map +1 -0
- package/dist/forms/createFieldTracker.spec.js +343 -0
- package/dist/forms/createFormStore.spec.d.ts +2 -0
- package/dist/forms/createFormStore.spec.d.ts.map +1 -0
- package/dist/forms/createFormStore.spec.js +689 -0
- package/dist/forms/createFormStore.svelte.js +0 -1
- package/dist/index.d.ts +4 -112
- package/dist/index.js +4 -190
- package/dist/patterns/data/DataGrid.spec.d.ts +2 -0
- package/dist/patterns/data/DataGrid.spec.d.ts.map +1 -0
- package/dist/patterns/data/DataGrid.spec.js +159 -0
- package/dist/patterns/data/DataList.spec.d.ts +2 -0
- package/dist/patterns/data/DataList.spec.d.ts.map +1 -0
- package/dist/patterns/data/DataList.spec.js +158 -0
- package/dist/patterns/data/DataTable.spec.d.ts +2 -0
- package/dist/patterns/data/DataTable.spec.d.ts.map +1 -0
- package/dist/patterns/data/DataTable.spec.js +196 -0
- package/dist/patterns/forms/FormActions.spec.js +10 -3
- package/dist/patterns/forms/FormGrid.spec.d.ts +2 -0
- package/dist/patterns/forms/FormGrid.spec.d.ts.map +1 -0
- package/dist/patterns/forms/FormGrid.spec.js +125 -0
- package/dist/patterns/forms/FormSection.spec.d.ts +2 -0
- package/dist/patterns/forms/FormSection.spec.d.ts.map +1 -0
- package/dist/patterns/forms/FormSection.spec.js +153 -0
- package/dist/patterns/layout/Sidebar.spec.d.ts +2 -0
- package/dist/patterns/layout/Sidebar.spec.d.ts.map +1 -0
- package/dist/patterns/layout/Sidebar.spec.js +159 -0
- package/dist/patterns/navigation/BottomNav.svelte +4 -4
- package/dist/patterns/navigation/Header.spec.js +33 -24
- package/dist/patterns/page/PageHeader.spec.d.ts +2 -0
- package/dist/patterns/page/PageHeader.spec.d.ts.map +1 -0
- package/dist/patterns/page/PageHeader.spec.js +167 -0
- package/dist/patterns/page/PageLayout.spec.d.ts +2 -0
- package/dist/patterns/page/PageLayout.spec.d.ts.map +1 -0
- package/dist/patterns/page/PageLayout.spec.js +145 -0
- package/dist/patterns/page/PageLoader.spec.js +5 -2
- package/dist/patterns/page/SectionHeader.spec.d.ts +2 -0
- package/dist/patterns/page/SectionHeader.spec.d.ts.map +1 -0
- package/dist/patterns/page/SectionHeader.spec.js +197 -0
- package/dist/presets/badges.spec.d.ts +2 -0
- package/dist/presets/badges.spec.d.ts.map +1 -0
- package/dist/presets/badges.spec.js +172 -0
- package/dist/presets/buttons.spec.d.ts +2 -0
- package/dist/presets/buttons.spec.d.ts.map +1 -0
- package/dist/presets/buttons.spec.js +135 -0
- package/dist/primitives/Accordion/Accordion.spec.d.ts +2 -0
- package/dist/primitives/Accordion/Accordion.spec.d.ts.map +1 -0
- package/dist/primitives/Accordion/Accordion.spec.js +83 -0
- package/dist/primitives/Accordion/AccordionItem.spec.d.ts +2 -0
- package/dist/primitives/Accordion/AccordionItem.spec.d.ts.map +1 -0
- package/dist/primitives/Accordion/AccordionItem.spec.js +661 -0
- package/dist/primitives/Accordion/AccordionItemWrapper.test.svelte +107 -0
- package/dist/primitives/Accordion/AccordionItemWrapper.test.svelte.d.ts +35 -0
- package/dist/primitives/Accordion/AccordionItemWrapper.test.svelte.d.ts.map +1 -0
- package/dist/primitives/Alert/Alert.spec.js +5 -2
- package/dist/primitives/Avatar/Avatar.spec.d.ts +2 -0
- package/dist/primitives/Avatar/Avatar.spec.d.ts.map +1 -0
- package/dist/primitives/Avatar/Avatar.spec.js +211 -0
- package/dist/primitives/Badges/Badge.spec.js +109 -68
- package/dist/primitives/BottomSheet/BottomSheet.spec.js +36 -27
- package/dist/primitives/BottomSheet/BottomSheetWrapper.test.svelte +13 -0
- package/dist/primitives/BottomSheet/BottomSheetWrapper.test.svelte.d.ts +7 -0
- package/dist/primitives/BottomSheet/BottomSheetWrapper.test.svelte.d.ts.map +1 -0
- package/dist/primitives/Breadcrumb/Breadcrumb.spec.js +15 -13
- package/dist/primitives/Breadcrumb/Breadcrumb.svelte +5 -5
- package/dist/primitives/Button/Button.spec.js +83 -71
- package/dist/primitives/Button/ButtonSaveDemo.spec.js +100 -2
- package/dist/primitives/Button/ButtonVariantShowcase.spec.d.ts +2 -0
- package/dist/primitives/Button/ButtonVariantShowcase.spec.d.ts.map +1 -0
- package/dist/primitives/Button/ButtonVariantShowcase.spec.js +202 -0
- package/dist/primitives/Card.spec.js +1 -1
- package/dist/primitives/Checkbox/Checkbox.spec.d.ts +2 -0
- package/dist/primitives/Checkbox/Checkbox.spec.d.ts.map +1 -0
- package/dist/primitives/Checkbox/Checkbox.spec.js +252 -0
- package/dist/primitives/DarkModeToggle.spec.js +84 -51
- package/dist/primitives/Drawer/Drawer.spec.d.ts +2 -0
- package/dist/primitives/Drawer/Drawer.spec.d.ts.map +1 -0
- package/dist/primitives/Drawer/Drawer.spec.js +212 -0
- package/dist/primitives/Dropdown/Dropdown.spec.d.ts +2 -0
- package/dist/primitives/Dropdown/Dropdown.spec.d.ts.map +1 -0
- package/dist/primitives/Dropdown/Dropdown.spec.js +366 -0
- package/dist/primitives/Dropdown/DropdownItem.spec.d.ts +2 -0
- package/dist/primitives/Dropdown/DropdownItem.spec.d.ts.map +1 -0
- package/dist/primitives/Dropdown/DropdownItem.spec.js +182 -0
- package/dist/primitives/Icons/iconTestUtils.spec.d.ts +2 -0
- package/dist/primitives/Icons/iconTestUtils.spec.d.ts.map +1 -0
- package/dist/primitives/Icons/iconTestUtils.spec.js +235 -0
- package/dist/primitives/Input/Input.spec.js +14 -14
- package/dist/primitives/Input/Input.svelte +1 -14
- package/dist/primitives/Input/Input.svelte.d.ts.map +1 -1
- package/dist/primitives/Input/Select.spec.js +11 -17
- package/dist/primitives/Input/Textarea.spec.d.ts +2 -0
- package/dist/primitives/Input/Textarea.spec.d.ts.map +1 -0
- package/dist/primitives/Input/Textarea.spec.js +255 -0
- package/dist/primitives/Label/Label.spec.d.ts +2 -0
- package/dist/primitives/Label/Label.spec.d.ts.map +1 -0
- package/dist/primitives/Label/Label.spec.js +157 -0
- package/dist/primitives/Modal/Modal.spec.js +29 -25
- package/dist/primitives/Modal/ModalTestWrapper.svelte +65 -0
- package/dist/primitives/Modal/ModalTestWrapper.svelte.d.ts +23 -0
- package/dist/primitives/Modal/ModalTestWrapper.svelte.d.ts.map +1 -0
- package/dist/primitives/NumberInput/NumberInput.spec.d.ts +2 -0
- package/dist/primitives/NumberInput/NumberInput.spec.d.ts.map +1 -0
- package/dist/primitives/NumberInput/NumberInput.spec.js +235 -0
- package/dist/primitives/Pagination/Pagination.spec.d.ts +2 -0
- package/dist/primitives/Pagination/Pagination.spec.d.ts.map +1 -0
- package/dist/primitives/Pagination/Pagination.spec.js +266 -0
- package/dist/primitives/Radio/Radio.spec.d.ts +2 -0
- package/dist/primitives/Radio/Radio.spec.d.ts.map +1 -0
- package/dist/primitives/Radio/Radio.spec.js +206 -0
- package/dist/primitives/Skeleton/CardPlaceholder.spec.d.ts +2 -0
- package/dist/primitives/Skeleton/CardPlaceholder.spec.d.ts.map +1 -0
- package/dist/primitives/Skeleton/CardPlaceholder.spec.js +156 -0
- package/dist/primitives/Skeleton/ImagePlaceholder.spec.d.ts +2 -0
- package/dist/primitives/Skeleton/ImagePlaceholder.spec.d.ts.map +1 -0
- package/dist/primitives/Skeleton/ImagePlaceholder.spec.js +120 -0
- package/dist/primitives/Skeleton/ListPlaceholder.spec.d.ts +2 -0
- package/dist/primitives/Skeleton/ListPlaceholder.spec.d.ts.map +1 -0
- package/dist/primitives/Skeleton/ListPlaceholder.spec.js +220 -0
- package/dist/primitives/Skeleton/Skeleton.spec.d.ts +2 -0
- package/dist/primitives/Skeleton/Skeleton.spec.d.ts.map +1 -0
- package/dist/primitives/Skeleton/Skeleton.spec.js +173 -0
- package/dist/primitives/Spinner/Spinner.spec.js +25 -29
- package/dist/primitives/Tabs/TabItem.spec.d.ts +2 -0
- package/dist/primitives/Tabs/TabItem.spec.d.ts.map +1 -0
- package/dist/primitives/Tabs/TabItem.spec.js +130 -0
- package/dist/primitives/Tabs/Tabs.spec.d.ts +2 -0
- package/dist/primitives/Tabs/Tabs.spec.d.ts.map +1 -0
- package/dist/primitives/Tabs/Tabs.spec.js +295 -0
- package/dist/primitives/Tabs/TabsWithItems.test.svelte +18 -0
- package/dist/primitives/Tabs/TabsWithItems.test.svelte.d.ts +16 -0
- package/dist/primitives/Tabs/TabsWithItems.test.svelte.d.ts.map +1 -0
- package/dist/primitives/Toggle.spec.js +93 -77
- package/dist/primitives/Typography/Typography.spec.d.ts +2 -0
- package/dist/primitives/Typography/Typography.spec.d.ts.map +1 -0
- package/dist/primitives/Typography/Typography.spec.js +183 -0
- package/dist/primitives/ValidationError.spec.js +1 -1
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.js +3 -0
- package/dist/recipes/CropImage/CropImage.spec.js +1 -9
- package/dist/recipes/ImageUploader/ImageUploader.spec.d.ts +2 -0
- package/dist/recipes/ImageUploader/ImageUploader.spec.d.ts.map +1 -0
- package/dist/recipes/ImageUploader/ImageUploader.spec.js +1351 -0
- package/dist/recipes/SuperLogin/SuperLogin.spec.d.ts +2 -0
- package/dist/recipes/SuperLogin/SuperLogin.spec.d.ts.map +1 -0
- package/dist/recipes/SuperLogin/SuperLogin.spec.js +1436 -0
- package/dist/recipes/feedback/EmptyState/EmptyState.spec.d.ts +2 -0
- package/dist/recipes/feedback/EmptyState/EmptyState.spec.d.ts.map +1 -0
- package/dist/recipes/feedback/EmptyState/EmptyState.spec.js +202 -0
- package/dist/recipes/feedback/ErrorDisplay.spec.js +6 -6
- package/dist/recipes/feedback/StatusIndicator/StatusIndicator.spec.js +21 -17
- package/dist/recipes/fields/CheckboxField.spec.d.ts +2 -0
- package/dist/recipes/fields/CheckboxField.spec.d.ts.map +1 -0
- package/dist/recipes/fields/CheckboxField.spec.js +135 -0
- package/dist/recipes/fields/FormField.spec.d.ts +2 -0
- package/dist/recipes/fields/FormField.spec.d.ts.map +1 -0
- package/dist/recipes/fields/FormField.spec.js +159 -0
- package/dist/recipes/fields/RadioGroup.spec.d.ts +2 -0
- package/dist/recipes/fields/RadioGroup.spec.d.ts.map +1 -0
- package/dist/recipes/fields/RadioGroup.spec.js +199 -0
- package/dist/recipes/fields/SelectField.spec.d.ts +2 -0
- package/dist/recipes/fields/SelectField.spec.d.ts.map +1 -0
- package/dist/recipes/fields/SelectField.spec.js +188 -0
- package/dist/recipes/fields/TextareaField.spec.d.ts +2 -0
- package/dist/recipes/fields/TextareaField.spec.d.ts.map +1 -0
- package/dist/recipes/fields/TextareaField.spec.js +205 -0
- package/dist/recipes/fields/ToggleField.spec.d.ts +2 -0
- package/dist/recipes/fields/ToggleField.spec.d.ts.map +1 -0
- package/dist/recipes/fields/ToggleField.spec.js +153 -0
- package/dist/recipes/inputs/MultiSelect.spec.js +4 -3
- package/dist/recipes/inputs/MultiSelect.svelte +10 -3
- package/dist/recipes/inputs/MultiSelect.svelte.d.ts +2 -0
- package/dist/recipes/inputs/MultiSelect.svelte.d.ts.map +1 -1
- package/dist/recipes/inputs/OTPInput.spec.js +52 -39
- package/dist/recipes/inputs/PasswordInput.spec.d.ts +2 -0
- package/dist/recipes/inputs/PasswordInput.spec.d.ts.map +1 -0
- package/dist/recipes/inputs/PasswordInput.spec.js +410 -0
- package/dist/recipes/inputs/PasswordStrengthIndicator/PasswordStrengthIndicator.spec.js +253 -173
- package/dist/recipes/inputs/PasswordStrengthIndicator/TestWrapper.svelte +71 -0
- package/dist/recipes/inputs/PasswordStrengthIndicator/TestWrapper.svelte.d.ts +9 -0
- package/dist/recipes/inputs/PasswordStrengthIndicator/TestWrapper.svelte.d.ts.map +1 -0
- package/dist/recipes/inputs/PlaceAutocomplete/PlaceAutocomplete.spec.js +1246 -300
- package/dist/recipes/inputs/Search.spec.d.ts +2 -0
- package/dist/recipes/inputs/Search.spec.d.ts.map +1 -0
- package/dist/recipes/inputs/Search.spec.js +177 -0
- package/dist/recipes/inputs/SelectDropdown.spec.d.ts +2 -0
- package/dist/recipes/inputs/SelectDropdown.spec.d.ts.map +1 -0
- package/dist/recipes/inputs/SelectDropdown.spec.js +512 -0
- package/dist/recipes/modals/AlertModal.spec.d.ts +2 -0
- package/dist/recipes/modals/AlertModal.spec.d.ts.map +1 -0
- package/dist/recipes/modals/AlertModal.spec.js +432 -0
- package/dist/recipes/modals/ConfirmationModal.spec.js +36 -21
- package/dist/recipes/modals/InputModal.spec.d.ts +2 -0
- package/dist/recipes/modals/InputModal.spec.d.ts.map +1 -0
- package/dist/recipes/modals/InputModal.spec.js +872 -0
- package/dist/recipes/modals/ModalTestWrapper.spec.d.ts +2 -0
- package/dist/recipes/modals/ModalTestWrapper.spec.d.ts.map +1 -0
- package/dist/recipes/modals/ModalTestWrapper.spec.js +502 -0
- package/dist/recipes/modals/StatusModal.spec.d.ts +2 -0
- package/dist/recipes/modals/StatusModal.spec.d.ts.map +1 -0
- package/dist/recipes/modals/StatusModal.spec.js +599 -0
- package/dist/services/ShowService.spec.js +18 -15
- package/dist/stories/ButtonAuditDashboard.spec.d.ts +2 -0
- package/dist/stories/ButtonAuditDashboard.spec.d.ts.map +1 -0
- package/dist/stories/ButtonAuditDashboard.spec.js +913 -0
- package/dist/stories/ButtonAuditReview.spec.d.ts +2 -0
- package/dist/stories/ButtonAuditReview.spec.d.ts.map +1 -0
- package/dist/stories/ButtonAuditReview.spec.js +422 -0
- package/dist/stories/ButtonGridView.spec.d.ts +2 -0
- package/dist/stories/ButtonGridView.spec.d.ts.map +1 -0
- package/dist/stories/ButtonGridView.spec.js +667 -0
- package/dist/stories/ButtonShowcase.spec.d.ts +2 -0
- package/dist/stories/ButtonShowcase.spec.d.ts.map +1 -0
- package/dist/stories/ButtonShowcase.spec.js +499 -0
- package/dist/stories/PatternsGallery.spec.d.ts +2 -0
- package/dist/stories/PatternsGallery.spec.d.ts.map +1 -0
- package/dist/stories/PatternsGallery.spec.js +514 -0
- package/dist/stories/PrimitivesGallery.spec.d.ts +2 -0
- package/dist/stories/PrimitivesGallery.spec.d.ts.map +1 -0
- package/dist/stories/PrimitivesGallery.spec.js +813 -0
- package/dist/stories/RecipesGallery.spec.d.ts +2 -0
- package/dist/stories/RecipesGallery.spec.d.ts.map +1 -0
- package/dist/stories/RecipesGallery.spec.js +299 -0
- package/dist/stripe/useStripeTheme.spec.d.ts +2 -0
- package/dist/stripe/useStripeTheme.spec.d.ts.map +1 -0
- package/dist/stripe/useStripeTheme.spec.js +793 -0
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +6 -5
- package/dist/telemetry.spec.js +495 -12
- package/dist/tokens/__tests__/colors.test.d.ts +2 -0
- package/dist/tokens/__tests__/colors.test.d.ts.map +1 -0
- package/dist/tokens/__tests__/colors.test.js +152 -0
- package/dist/tokens/__tests__/radius.test.d.ts +2 -0
- package/dist/tokens/__tests__/radius.test.d.ts.map +1 -0
- package/dist/tokens/__tests__/radius.test.js +118 -0
- package/dist/tokens/__tests__/shadows.test.d.ts +2 -0
- package/dist/tokens/__tests__/shadows.test.d.ts.map +1 -0
- package/dist/tokens/__tests__/shadows.test.js +105 -0
- package/dist/tokens/__tests__/spacing.test.js +11 -8
- package/dist/tokens/__tests__/typography.test.d.ts +2 -0
- package/dist/tokens/__tests__/typography.test.d.ts.map +1 -0
- package/dist/tokens/__tests__/typography.test.js +156 -0
- package/dist/tokens/__tests__/z-index.test.d.ts +2 -0
- package/dist/tokens/__tests__/z-index.test.d.ts.map +1 -0
- package/dist/tokens/__tests__/z-index.test.js +121 -0
- package/dist/utils/apiConfig.spec.js +102 -1
- package/dist/utils/formatters.spec.d.ts +2 -0
- package/dist/utils/formatters.spec.d.ts.map +1 -0
- package/dist/utils/formatters.spec.js +82 -0
- package/dist/utils/transitions.spec.d.ts +2 -0
- package/dist/utils/transitions.spec.d.ts.map +1 -0
- package/dist/utils/transitions.spec.js +130 -0
- package/package.json +8 -3
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/svelte';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { expect, describe, test, vi } from 'vitest';
|
|
4
|
+
import Textarea from './Textarea.svelte';
|
|
5
|
+
|
|
6
|
+
describe('Textarea Component', () => {
|
|
7
|
+
test('renders a textarea element', () => {
|
|
8
|
+
const { container } = render(Textarea);
|
|
9
|
+
expect(container.querySelector('textarea')).toBeInTheDocument();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('renders inside a wrapper div', () => {
|
|
13
|
+
const { container } = render(Textarea);
|
|
14
|
+
expect(container.querySelector('div.flex.flex-col')).toBeInTheDocument();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('applies custom className to textarea', () => {
|
|
18
|
+
const { container } = render(Textarea, { props: { class: 'custom-textarea' } });
|
|
19
|
+
const textarea = container.querySelector('textarea');
|
|
20
|
+
expect(textarea).toHaveClass('custom-textarea');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('passes through additional props', () => {
|
|
24
|
+
const { container } = render(Textarea, { props: { 'data-testid': 'my-textarea' } });
|
|
25
|
+
const textarea = container.querySelector('[data-testid="my-textarea"]');
|
|
26
|
+
expect(textarea).toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('Textarea Props', () => {
|
|
31
|
+
test('value defaults to empty string', () => {
|
|
32
|
+
const { container } = render(Textarea);
|
|
33
|
+
const textarea = container.querySelector('textarea');
|
|
34
|
+
expect(textarea.value).toBe('');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('value can be set', () => {
|
|
38
|
+
const { container } = render(Textarea, { props: { value: 'Hello world' } });
|
|
39
|
+
const textarea = container.querySelector('textarea');
|
|
40
|
+
expect(textarea.value).toBe('Hello world');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('placeholder prop is applied', () => {
|
|
44
|
+
const { container } = render(Textarea, { props: { placeholder: 'Enter text...' } });
|
|
45
|
+
const textarea = container.querySelector('textarea');
|
|
46
|
+
expect(textarea).toHaveAttribute('placeholder', 'Enter text...');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('rows defaults to 4', () => {
|
|
50
|
+
const { container } = render(Textarea);
|
|
51
|
+
const textarea = container.querySelector('textarea');
|
|
52
|
+
expect(textarea).toHaveAttribute('rows', '4');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('rows can be customized', () => {
|
|
56
|
+
const { container } = render(Textarea, { props: { rows: 8 } });
|
|
57
|
+
const textarea = container.querySelector('textarea');
|
|
58
|
+
expect(textarea).toHaveAttribute('rows', '8');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('disabled prop disables textarea', () => {
|
|
62
|
+
const { container } = render(Textarea, { props: { disabled: true } });
|
|
63
|
+
const textarea = container.querySelector('textarea');
|
|
64
|
+
expect(textarea).toBeDisabled();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('readonly prop makes textarea readonly', () => {
|
|
68
|
+
const { container } = render(Textarea, { props: { readonly: true } });
|
|
69
|
+
const textarea = container.querySelector('textarea');
|
|
70
|
+
expect(textarea).toHaveAttribute('readonly');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('id prop is applied', () => {
|
|
74
|
+
const { container } = render(Textarea, { props: { id: 'description' } });
|
|
75
|
+
const textarea = container.querySelector('textarea');
|
|
76
|
+
expect(textarea).toHaveAttribute('id', 'description');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('name prop is applied', () => {
|
|
80
|
+
const { container } = render(Textarea, { props: { name: 'bio' } });
|
|
81
|
+
const textarea = container.querySelector('textarea');
|
|
82
|
+
expect(textarea).toHaveAttribute('name', 'bio');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('maxlength prop is applied', () => {
|
|
86
|
+
const { container } = render(Textarea, { props: { maxlength: 500 } });
|
|
87
|
+
const textarea = container.querySelector('textarea');
|
|
88
|
+
expect(textarea).toHaveAttribute('maxlength', '500');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('minlength prop is applied', () => {
|
|
92
|
+
const { container } = render(Textarea, { props: { minlength: 10 } });
|
|
93
|
+
const textarea = container.querySelector('textarea');
|
|
94
|
+
expect(textarea).toHaveAttribute('minlength', '10');
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('Textarea Label', () => {
|
|
99
|
+
test('renders label when provided', () => {
|
|
100
|
+
render(Textarea, { props: { label: 'Description' } });
|
|
101
|
+
expect(screen.getByText('Description')).toBeInTheDocument();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('label is associated with textarea via id', () => {
|
|
105
|
+
const { container } = render(Textarea, { props: { label: 'Bio', id: 'bio-field' } });
|
|
106
|
+
const label = container.querySelector('label');
|
|
107
|
+
expect(label).toHaveAttribute('for', 'bio-field');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('label shows asterisk when required', () => {
|
|
111
|
+
const { container } = render(Textarea, { props: { label: 'Description', required: true } });
|
|
112
|
+
expect(container.querySelector('.text-red-500')).toBeInTheDocument();
|
|
113
|
+
expect(screen.getByText('*')).toBeInTheDocument();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('no label element when label prop is empty', () => {
|
|
117
|
+
const { container } = render(Textarea, { props: { label: '' } });
|
|
118
|
+
expect(container.querySelector('label')).not.toBeInTheDocument();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe('Textarea Error State', () => {
|
|
123
|
+
test('shows error message when error prop is set', () => {
|
|
124
|
+
render(Textarea, { props: { error: 'This field is required' } });
|
|
125
|
+
expect(screen.getByText('This field is required')).toBeInTheDocument();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('has border-red-500 when error is present', () => {
|
|
129
|
+
const { container } = render(Textarea, { props: { error: 'Error' } });
|
|
130
|
+
const textarea = container.querySelector('textarea');
|
|
131
|
+
expect(textarea).toHaveClass('border-red-500');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('aria-invalid is true when error is present', () => {
|
|
135
|
+
const { container } = render(Textarea, { props: { error: 'Error' } });
|
|
136
|
+
const textarea = container.querySelector('textarea');
|
|
137
|
+
expect(textarea).toHaveAttribute('aria-invalid', 'true');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('aria-invalid is false when no error', () => {
|
|
141
|
+
const { container } = render(Textarea);
|
|
142
|
+
const textarea = container.querySelector('textarea');
|
|
143
|
+
expect(textarea).toHaveAttribute('aria-invalid', 'false');
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('Textarea Accessibility', () => {
|
|
148
|
+
test('aria-required is true when required', () => {
|
|
149
|
+
const { container } = render(Textarea, { props: { required: true } });
|
|
150
|
+
const textarea = container.querySelector('textarea');
|
|
151
|
+
expect(textarea).toHaveAttribute('aria-required', 'true');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test('aria-required is false when not required', () => {
|
|
155
|
+
const { container } = render(Textarea, { props: { required: false } });
|
|
156
|
+
const textarea = container.querySelector('textarea');
|
|
157
|
+
expect(textarea).toHaveAttribute('aria-required', 'false');
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
describe('Textarea Styling', () => {
|
|
162
|
+
test('has w-full class', () => {
|
|
163
|
+
const { container } = render(Textarea);
|
|
164
|
+
const textarea = container.querySelector('textarea');
|
|
165
|
+
expect(textarea).toHaveClass('w-full');
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test('has proper padding', () => {
|
|
169
|
+
const { container } = render(Textarea);
|
|
170
|
+
const textarea = container.querySelector('textarea');
|
|
171
|
+
expect(textarea).toHaveClass('p-2.5');
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test('has bg-gray-50 background', () => {
|
|
175
|
+
const { container } = render(Textarea);
|
|
176
|
+
const textarea = container.querySelector('textarea');
|
|
177
|
+
expect(textarea).toHaveClass('bg-gray-50');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test('has dark mode background', () => {
|
|
181
|
+
const { container } = render(Textarea);
|
|
182
|
+
const textarea = container.querySelector('textarea');
|
|
183
|
+
expect(textarea).toHaveClass('dark:bg-gray-800');
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('has rounded-lg border radius', () => {
|
|
187
|
+
const { container } = render(Textarea);
|
|
188
|
+
const textarea = container.querySelector('textarea');
|
|
189
|
+
expect(textarea).toHaveClass('rounded-lg');
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test('has resize-y for vertical resizing', () => {
|
|
193
|
+
const { container } = render(Textarea);
|
|
194
|
+
const textarea = container.querySelector('textarea');
|
|
195
|
+
expect(textarea).toHaveClass('resize-y');
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test('has focus ring classes', () => {
|
|
199
|
+
const { container } = render(Textarea);
|
|
200
|
+
const textarea = container.querySelector('textarea');
|
|
201
|
+
expect(textarea).toHaveClass('focus:ring-4');
|
|
202
|
+
expect(textarea).toHaveClass('focus:ring-blue-300');
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test('has opacity-50 and cursor-not-allowed when disabled', () => {
|
|
206
|
+
const { container } = render(Textarea, { props: { disabled: true } });
|
|
207
|
+
const textarea = container.querySelector('textarea');
|
|
208
|
+
expect(textarea).toHaveClass('opacity-50');
|
|
209
|
+
expect(textarea).toHaveClass('cursor-not-allowed');
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
describe('Textarea Events', () => {
|
|
214
|
+
test('calls oninput when user types', async () => {
|
|
215
|
+
const user = userEvent.setup();
|
|
216
|
+
const oninput = vi.fn();
|
|
217
|
+
const { container } = render(Textarea, { props: { oninput } });
|
|
218
|
+
|
|
219
|
+
const textarea = container.querySelector('textarea');
|
|
220
|
+
await user.type(textarea, 'Hello');
|
|
221
|
+
expect(oninput).toHaveBeenCalled();
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
test('calls onchange when textarea loses focus after change', async () => {
|
|
225
|
+
const user = userEvent.setup();
|
|
226
|
+
const onchange = vi.fn();
|
|
227
|
+
const { container } = render(Textarea, { props: { onchange } });
|
|
228
|
+
|
|
229
|
+
const textarea = container.querySelector('textarea');
|
|
230
|
+
await user.type(textarea, 'Hello');
|
|
231
|
+
await user.tab(); // Blur the textarea
|
|
232
|
+
expect(onchange).toHaveBeenCalled();
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
test('calls onblur when textarea loses focus', async () => {
|
|
236
|
+
const user = userEvent.setup();
|
|
237
|
+
const onblur = vi.fn();
|
|
238
|
+
const { container } = render(Textarea, { props: { onblur } });
|
|
239
|
+
|
|
240
|
+
const textarea = container.querySelector('textarea');
|
|
241
|
+
await user.click(textarea);
|
|
242
|
+
await user.tab();
|
|
243
|
+
expect(onblur).toHaveBeenCalled();
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
test('calls onfocus when textarea receives focus', async () => {
|
|
247
|
+
const user = userEvent.setup();
|
|
248
|
+
const onfocus = vi.fn();
|
|
249
|
+
const { container } = render(Textarea, { props: { onfocus } });
|
|
250
|
+
|
|
251
|
+
const textarea = container.querySelector('textarea');
|
|
252
|
+
await user.click(textarea);
|
|
253
|
+
expect(onfocus).toHaveBeenCalled();
|
|
254
|
+
});
|
|
255
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Label.spec.d.ts","sourceRoot":"","sources":["../../../src/lib/primitives/Label/Label.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/svelte';
|
|
2
|
+
import { expect, describe, test } from 'vitest';
|
|
3
|
+
import Label from './Label.svelte';
|
|
4
|
+
|
|
5
|
+
describe('Label Component', () => {
|
|
6
|
+
test('renders a label element', () => {
|
|
7
|
+
const { container } = render(Label);
|
|
8
|
+
expect(container.querySelector('label')).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('applies custom className', () => {
|
|
12
|
+
const { container } = render(Label, { props: { class: 'custom-label' } });
|
|
13
|
+
const label = container.querySelector('label');
|
|
14
|
+
expect(label).toHaveClass('custom-label');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('passes through additional props', () => {
|
|
18
|
+
const { container } = render(Label, { props: { 'data-testid': 'my-label' } });
|
|
19
|
+
const label = container.querySelector('[data-testid="my-label"]');
|
|
20
|
+
expect(label).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('passes for attribute', () => {
|
|
24
|
+
const { container } = render(Label, { props: { for: 'input-id' } });
|
|
25
|
+
const label = container.querySelector('label');
|
|
26
|
+
expect(label).toHaveAttribute('for', 'input-id');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('Label Colors', () => {
|
|
31
|
+
test('default color is gray', () => {
|
|
32
|
+
const { container } = render(Label);
|
|
33
|
+
const label = container.querySelector('label');
|
|
34
|
+
expect(label).toHaveClass('text-gray-900');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('gray color applies text-gray-900', () => {
|
|
38
|
+
const { container } = render(Label, { props: { color: 'gray' } });
|
|
39
|
+
const label = container.querySelector('label');
|
|
40
|
+
expect(label).toHaveClass('text-gray-900');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('green color applies text-green-700', () => {
|
|
44
|
+
const { container } = render(Label, { props: { color: 'green' } });
|
|
45
|
+
const label = container.querySelector('label');
|
|
46
|
+
expect(label).toHaveClass('text-green-700');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('red color applies text-red-700', () => {
|
|
50
|
+
const { container } = render(Label, { props: { color: 'red' } });
|
|
51
|
+
const label = container.querySelector('label');
|
|
52
|
+
expect(label).toHaveClass('text-red-700');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('disabled color applies text-gray-400', () => {
|
|
56
|
+
const { container } = render(Label, { props: { color: 'disabled' } });
|
|
57
|
+
const label = container.querySelector('label');
|
|
58
|
+
expect(label).toHaveClass('text-gray-400');
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('Label Dark Mode', () => {
|
|
63
|
+
test('gray has dark mode class', () => {
|
|
64
|
+
const { container } = render(Label, { props: { color: 'gray' } });
|
|
65
|
+
const label = container.querySelector('label');
|
|
66
|
+
expect(label).toHaveClass('dark:text-gray-300');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('green has dark mode class', () => {
|
|
70
|
+
const { container } = render(Label, { props: { color: 'green' } });
|
|
71
|
+
const label = container.querySelector('label');
|
|
72
|
+
expect(label).toHaveClass('dark:text-green-500');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('red has dark mode class', () => {
|
|
76
|
+
const { container } = render(Label, { props: { color: 'red' } });
|
|
77
|
+
const label = container.querySelector('label');
|
|
78
|
+
expect(label).toHaveClass('dark:text-red-500');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('disabled has dark mode class', () => {
|
|
82
|
+
const { container } = render(Label, { props: { color: 'disabled' } });
|
|
83
|
+
const label = container.querySelector('label');
|
|
84
|
+
expect(label).toHaveClass('dark:text-gray-500');
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('Label Show Prop', () => {
|
|
89
|
+
test('shows label by default (show=true)', () => {
|
|
90
|
+
const { container } = render(Label);
|
|
91
|
+
expect(container.querySelector('label')).toBeInTheDocument();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('hides label when show is false', () => {
|
|
95
|
+
const { container } = render(Label, { props: { show: false } });
|
|
96
|
+
expect(container.querySelector('label')).not.toBeInTheDocument();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('renders children without label when show is false', () => {
|
|
100
|
+
// When show=false, children render without label wrapper
|
|
101
|
+
const { container } = render(Label, { props: { show: false } });
|
|
102
|
+
expect(container.querySelector('label')).not.toBeInTheDocument();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('Label Default Styling', () => {
|
|
107
|
+
test('has text-sm class', () => {
|
|
108
|
+
const { container } = render(Label);
|
|
109
|
+
const label = container.querySelector('label');
|
|
110
|
+
expect(label).toHaveClass('text-sm');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('has font-medium class', () => {
|
|
114
|
+
const { container } = render(Label);
|
|
115
|
+
const label = container.querySelector('label');
|
|
116
|
+
expect(label).toHaveClass('font-medium');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('has block display', () => {
|
|
120
|
+
const { container } = render(Label);
|
|
121
|
+
const label = container.querySelector('label');
|
|
122
|
+
expect(label).toHaveClass('block');
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('has rtl:text-right for RTL support', () => {
|
|
126
|
+
const { container } = render(Label);
|
|
127
|
+
const label = container.querySelector('label');
|
|
128
|
+
expect(label).toHaveClass('rtl:text-right');
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe('Label Custom Default Class', () => {
|
|
133
|
+
test('accepts defaultClass prop', () => {
|
|
134
|
+
const { container } = render(Label, { props: { defaultClass: 'text-lg font-bold' } });
|
|
135
|
+
const label = container.querySelector('label');
|
|
136
|
+
expect(label).toHaveClass('text-lg');
|
|
137
|
+
expect(label).toHaveClass('font-bold');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('defaultClass replaces default styling', () => {
|
|
141
|
+
const { container } = render(Label, { props: { defaultClass: 'custom-default' } });
|
|
142
|
+
const label = container.querySelector('label');
|
|
143
|
+
expect(label).toHaveClass('custom-default');
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('Label Class Composition', () => {
|
|
148
|
+
test('combines defaultClass, color class, and custom class', () => {
|
|
149
|
+
const { container } = render(Label, {
|
|
150
|
+
props: { color: 'green', class: 'extra-class' }
|
|
151
|
+
});
|
|
152
|
+
const label = container.querySelector('label');
|
|
153
|
+
expect(label).toHaveClass('text-sm'); // from defaultClass
|
|
154
|
+
expect(label).toHaveClass('text-green-700'); // from color
|
|
155
|
+
expect(label).toHaveClass('extra-class'); // from custom class
|
|
156
|
+
});
|
|
157
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { render, screen, fireEvent } from '@testing-library/svelte';
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
|
-
import { expect, describe, test } from 'vitest';
|
|
3
|
+
import { expect, describe, test, vi } from 'vitest';
|
|
4
4
|
import ModalTestWrapper from './ModalTestWrapper.svelte';
|
|
5
5
|
|
|
6
6
|
function setupTest(args) {
|
|
7
7
|
const user = userEvent.setup();
|
|
8
|
-
const { component } = render(ModalTestWrapper, { props: { ...args } });
|
|
9
|
-
return { user, component };
|
|
8
|
+
const { component, rerender } = render(ModalTestWrapper, { props: { ...args } });
|
|
9
|
+
return { user, component, rerender };
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
describe('Modal Component Tests', () => {
|
|
@@ -22,9 +22,9 @@ describe('Modal Component Tests', () => {
|
|
|
22
22
|
warningText: 'Test Warning'
|
|
23
23
|
});
|
|
24
24
|
// Modal renders both mobile and desktop versions, so use getAllByText
|
|
25
|
-
expect(screen.getAllByText('Test Title').length).toBeGreaterThan(0);
|
|
26
|
-
expect(screen.getAllByText(
|
|
27
|
-
expect(screen.getAllByText(
|
|
25
|
+
expect(screen.getAllByText((content, element) => content.includes('Test Title')).length).toBeGreaterThan(0);
|
|
26
|
+
expect(screen.getAllByText((content, element) => content.includes('Test Description')).length).toBeGreaterThan(0);
|
|
27
|
+
expect(screen.getAllByText((content, element) => content.includes('Test Warning')).length).toBeGreaterThan(0);
|
|
28
28
|
expect(screen.getAllByRole('button', { name: /Cancel/i }).length).toBeGreaterThan(0);
|
|
29
29
|
expect(screen.getAllByRole('button', { name: /Confirm/i }).length).toBeGreaterThan(0);
|
|
30
30
|
});
|
|
@@ -52,29 +52,29 @@ describe('Modal Component Tests', () => {
|
|
|
52
52
|
warningText,
|
|
53
53
|
});
|
|
54
54
|
// Modal renders both mobile and desktop versions
|
|
55
|
-
expect(screen.getAllByText(title).length).toBeGreaterThan(0);
|
|
56
|
-
expect(screen.getAllByText(
|
|
57
|
-
expect(screen.getAllByText(
|
|
55
|
+
expect(screen.getAllByText((content) => content.includes(title)).length).toBeGreaterThan(0);
|
|
56
|
+
expect(screen.getAllByText((content) => content.includes(description)).length).toBeGreaterThan(0);
|
|
57
|
+
expect(screen.getAllByText((content) => content.includes(warningText)).length).toBeGreaterThan(0);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
test('Dispatches cancel event on escape key press', async () => {
|
|
61
|
-
|
|
61
|
+
// Create a mock function to track cancel calls
|
|
62
|
+
const oncancel = vi.fn();
|
|
63
|
+
|
|
64
|
+
const { user } = setupTest({
|
|
62
65
|
show: true,
|
|
63
|
-
title: 'Test Title'
|
|
66
|
+
title: 'Test Title',
|
|
67
|
+
oncancel
|
|
64
68
|
});
|
|
65
69
|
|
|
66
70
|
// Verify modal is open
|
|
67
|
-
expect(screen.getAllByText('Test Title').length).toBeGreaterThan(0);
|
|
68
|
-
|
|
69
|
-
// Listen for the cancel event
|
|
70
|
-
let cancelCalled = false;
|
|
71
|
-
component.$on('cancel', () => { cancelCalled = true; });
|
|
71
|
+
expect(screen.getAllByText((content) => content.includes('Test Title')).length).toBeGreaterThan(0);
|
|
72
72
|
|
|
73
73
|
// Press Escape key
|
|
74
74
|
await fireEvent.keyDown(window, { key: 'Escape' });
|
|
75
75
|
|
|
76
|
-
// Cancel
|
|
77
|
-
expect(
|
|
76
|
+
// Cancel callback should be called
|
|
77
|
+
expect(oncancel).toHaveBeenCalled();
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
test('Prevents propagation of click events within modal', async () => {
|
|
@@ -83,13 +83,17 @@ describe('Modal Component Tests', () => {
|
|
|
83
83
|
title: 'Test Title'
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
// Find the modal
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
modalContent.
|
|
86
|
+
// Find the modal content (first instance)
|
|
87
|
+
const modalElements = screen.getAllByText((content) => content.includes('Test Title'));
|
|
88
|
+
expect(modalElements.length).toBeGreaterThan(0);
|
|
89
|
+
|
|
90
|
+
const modalContent = modalElements[0].closest('.md\\:hidden, .hidden');
|
|
91
|
+
if (modalContent) {
|
|
92
|
+
const clickEvent = new MouseEvent('click', { bubbles: true });
|
|
93
|
+
modalContent.dispatchEvent(clickEvent);
|
|
91
94
|
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
// Modal should still be visible
|
|
96
|
+
expect(screen.getAllByText((content) => content.includes('Test Title')).length).toBeGreaterThan(0);
|
|
97
|
+
}
|
|
94
98
|
});
|
|
95
99
|
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import Modal from "./Modal.svelte";
|
|
4
|
+
import Button from "../Button/Button.svelte";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
/** Whether the modal is visible */
|
|
8
|
+
show?: boolean;
|
|
9
|
+
/** Modal title */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** Modal description */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** Warning text */
|
|
14
|
+
warningText?: string;
|
|
15
|
+
/** Callback when modal is cancelled */
|
|
16
|
+
oncancel?: () => void;
|
|
17
|
+
/** Custom header snippet */
|
|
18
|
+
customHeader?: Snippet;
|
|
19
|
+
/** Custom body snippet */
|
|
20
|
+
customBody?: Snippet;
|
|
21
|
+
/** Custom footer snippet */
|
|
22
|
+
customFooter?: Snippet;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let {
|
|
26
|
+
show = $bindable(false),
|
|
27
|
+
title = '',
|
|
28
|
+
description = '',
|
|
29
|
+
warningText = '',
|
|
30
|
+
oncancel,
|
|
31
|
+
customHeader,
|
|
32
|
+
customBody,
|
|
33
|
+
customFooter
|
|
34
|
+
}: Props = $props();
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<Modal bind:show {oncancel}>
|
|
38
|
+
{#snippet header()}
|
|
39
|
+
{#if customHeader}
|
|
40
|
+
{@render customHeader()}
|
|
41
|
+
{:else}
|
|
42
|
+
{title}
|
|
43
|
+
{/if}
|
|
44
|
+
{/snippet}
|
|
45
|
+
|
|
46
|
+
{#snippet body()}
|
|
47
|
+
{#if customBody}
|
|
48
|
+
{@render customBody()}
|
|
49
|
+
{:else}
|
|
50
|
+
{description}
|
|
51
|
+
{#if warningText}
|
|
52
|
+
<br /> {warningText}
|
|
53
|
+
{/if}
|
|
54
|
+
{/if}
|
|
55
|
+
{/snippet}
|
|
56
|
+
|
|
57
|
+
{#snippet footer()}
|
|
58
|
+
{#if customFooter}
|
|
59
|
+
{@render customFooter()}
|
|
60
|
+
{:else}
|
|
61
|
+
<Button variant="alternative">Cancel</Button>
|
|
62
|
+
<Button variant="default">Confirm</Button>
|
|
63
|
+
{/if}
|
|
64
|
+
{/snippet}
|
|
65
|
+
</Modal>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Whether the modal is visible */
|
|
4
|
+
show?: boolean;
|
|
5
|
+
/** Modal title */
|
|
6
|
+
title?: string;
|
|
7
|
+
/** Modal description */
|
|
8
|
+
description?: string;
|
|
9
|
+
/** Warning text */
|
|
10
|
+
warningText?: string;
|
|
11
|
+
/** Callback when modal is cancelled */
|
|
12
|
+
oncancel?: () => void;
|
|
13
|
+
/** Custom header snippet */
|
|
14
|
+
customHeader?: Snippet;
|
|
15
|
+
/** Custom body snippet */
|
|
16
|
+
customBody?: Snippet;
|
|
17
|
+
/** Custom footer snippet */
|
|
18
|
+
customFooter?: Snippet;
|
|
19
|
+
}
|
|
20
|
+
declare const ModalTestWrapper: import("svelte").Component<Props, {}, "show">;
|
|
21
|
+
type ModalTestWrapper = ReturnType<typeof ModalTestWrapper>;
|
|
22
|
+
export default ModalTestWrapper;
|
|
23
|
+
//# sourceMappingURL=ModalTestWrapper.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalTestWrapper.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/primitives/Modal/ModalTestWrapper.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAKpC,UAAU,KAAK;IACb,mCAAmC;IACnC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,kBAAkB;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,4BAA4B;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0BAA0B;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4BAA4B;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAmDH,QAAA,MAAM,gBAAgB,+CAAwC,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberInput.spec.d.ts","sourceRoot":"","sources":["../../../src/lib/primitives/NumberInput/NumberInput.spec.js"],"names":[],"mappings":""}
|