@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
import { render, fireEvent } from '@testing-library/svelte';
|
|
2
|
+
import { render, fireEvent, cleanup } from '@testing-library/svelte';
|
|
3
3
|
import BottomSheet from './BottomSheet.svelte';
|
|
4
|
+
import BottomSheetWrapper from './BottomSheetWrapper.test.svelte';
|
|
4
5
|
|
|
5
6
|
describe('BottomSheet Component', () => {
|
|
6
7
|
beforeEach(() => {
|
|
@@ -10,17 +11,18 @@ describe('BottomSheet Component', () => {
|
|
|
10
11
|
|
|
11
12
|
afterEach(() => {
|
|
12
13
|
document.body.style.overflow = '';
|
|
14
|
+
cleanup();
|
|
13
15
|
});
|
|
14
16
|
|
|
15
17
|
it('does not render when show is false', () => {
|
|
16
18
|
const { container } = render(BottomSheet, { props: { show: false } });
|
|
17
|
-
const backdrop = container.querySelector('.
|
|
19
|
+
const backdrop = container.querySelector('.fixed.inset-0');
|
|
18
20
|
expect(backdrop).toBeFalsy();
|
|
19
21
|
});
|
|
20
22
|
|
|
21
23
|
it('renders when show is true', () => {
|
|
22
24
|
const { container } = render(BottomSheet, { props: { show: true } });
|
|
23
|
-
const backdrop = container.querySelector('.
|
|
25
|
+
const backdrop = container.querySelector('.fixed.inset-0');
|
|
24
26
|
expect(backdrop).toBeTruthy();
|
|
25
27
|
});
|
|
26
28
|
|
|
@@ -33,8 +35,8 @@ describe('BottomSheet Component', () => {
|
|
|
33
35
|
|
|
34
36
|
it('does not render title when not provided', () => {
|
|
35
37
|
const { container } = render(BottomSheet, { props: { show: true } });
|
|
36
|
-
const
|
|
37
|
-
expect(
|
|
38
|
+
const title = container.querySelector('h3');
|
|
39
|
+
expect(title).toBeFalsy();
|
|
38
40
|
});
|
|
39
41
|
|
|
40
42
|
it('locks body scroll when shown', async () => {
|
|
@@ -45,60 +47,65 @@ describe('BottomSheet Component', () => {
|
|
|
45
47
|
});
|
|
46
48
|
|
|
47
49
|
it('unlocks body scroll when hidden', async () => {
|
|
48
|
-
const {
|
|
50
|
+
const { rerender } = render(BottomSheetWrapper, { props: { show: true } });
|
|
49
51
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
52
|
+
expect(document.body.style.overflow).toBe('hidden');
|
|
50
53
|
|
|
51
|
-
|
|
54
|
+
await rerender({ show: false });
|
|
52
55
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
53
56
|
|
|
54
57
|
expect(document.body.style.overflow).toBe('');
|
|
55
58
|
});
|
|
56
59
|
|
|
57
60
|
it('dispatches close event on backdrop click', async () => {
|
|
58
|
-
const { container, component } = render(BottomSheet, { props: { show: true } });
|
|
59
|
-
const backdrop = container.querySelector('.bottom-sheet-backdrop');
|
|
60
|
-
|
|
61
61
|
let closeCalled = false;
|
|
62
|
-
|
|
62
|
+
const onclose = () => {
|
|
63
63
|
closeCalled = true;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const { container } = render(BottomSheet, {
|
|
67
|
+
props: { show: true, onclose }
|
|
64
68
|
});
|
|
69
|
+
const backdrop = container.querySelector('.fixed.inset-0');
|
|
65
70
|
|
|
66
71
|
await fireEvent.click(backdrop);
|
|
67
72
|
expect(closeCalled).toBe(true);
|
|
68
73
|
});
|
|
69
74
|
|
|
70
75
|
it('does not dispatch close when clicking sheet content', async () => {
|
|
71
|
-
const { container, component } = render(BottomSheet, { props: { show: true } });
|
|
72
|
-
const sheet = container.querySelector('.bottom-sheet');
|
|
73
|
-
|
|
74
76
|
let closeCalled = false;
|
|
75
|
-
|
|
77
|
+
const onclose = () => {
|
|
76
78
|
closeCalled = true;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const { container } = render(BottomSheet, {
|
|
82
|
+
props: { show: true, onclose }
|
|
77
83
|
});
|
|
84
|
+
const sheet = container.querySelector('.bg-white, .dark\\:bg-gray-800');
|
|
78
85
|
|
|
79
86
|
await fireEvent.click(sheet);
|
|
80
87
|
expect(closeCalled).toBe(false);
|
|
81
88
|
});
|
|
82
89
|
|
|
83
90
|
it('dispatches close event on Escape key', async () => {
|
|
84
|
-
const { component } = render(BottomSheet, { props: { show: true } });
|
|
85
|
-
|
|
86
91
|
let closeCalled = false;
|
|
87
|
-
|
|
92
|
+
const onclose = () => {
|
|
88
93
|
closeCalled = true;
|
|
89
|
-
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
render(BottomSheet, { props: { show: true, onclose } });
|
|
90
97
|
|
|
91
98
|
await fireEvent.keyDown(window, { key: 'Escape' });
|
|
92
99
|
expect(closeCalled).toBe(true);
|
|
93
100
|
});
|
|
94
101
|
|
|
95
102
|
it('does not dispatch close on Escape when not shown', async () => {
|
|
96
|
-
const { component } = render(BottomSheet, { props: { show: false } });
|
|
97
|
-
|
|
98
103
|
let closeCalled = false;
|
|
99
|
-
|
|
104
|
+
const onclose = () => {
|
|
100
105
|
closeCalled = true;
|
|
101
|
-
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
render(BottomSheet, { props: { show: false, onclose } });
|
|
102
109
|
|
|
103
110
|
await fireEvent.keyDown(window, { key: 'Escape' });
|
|
104
111
|
expect(closeCalled).toBe(false);
|
|
@@ -106,21 +113,23 @@ describe('BottomSheet Component', () => {
|
|
|
106
113
|
|
|
107
114
|
it('has handle bar element', () => {
|
|
108
115
|
const { container } = render(BottomSheet, { props: { show: true } });
|
|
109
|
-
|
|
116
|
+
// The handle is the gray bar with rounded corners
|
|
117
|
+
const handle = container.querySelector('.w-10.h-1.bg-gray-300');
|
|
110
118
|
expect(handle).toBeTruthy();
|
|
111
119
|
});
|
|
112
120
|
|
|
113
121
|
it('has content area for slot content', () => {
|
|
114
122
|
const { container } = render(BottomSheet, { props: { show: true } });
|
|
115
|
-
|
|
123
|
+
// The content area has overflow-y-auto class
|
|
124
|
+
const content = container.querySelector('.overflow-y-auto');
|
|
116
125
|
expect(content).toBeTruthy();
|
|
117
126
|
});
|
|
118
127
|
|
|
119
128
|
it('cleans up body overflow on destroy', () => {
|
|
120
|
-
const { component } = render(BottomSheet, { props: { show: true } });
|
|
121
129
|
document.body.style.overflow = 'hidden';
|
|
130
|
+
const { unmount } = render(BottomSheet, { props: { show: true } });
|
|
122
131
|
|
|
123
|
-
|
|
132
|
+
unmount();
|
|
124
133
|
|
|
125
134
|
expect(document.body.style.overflow).toBe('');
|
|
126
135
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
show?: boolean;
|
|
3
|
+
}
|
|
4
|
+
declare const BottomSheetWrapper: import("svelte").Component<Props, {}, "">;
|
|
5
|
+
type BottomSheetWrapper = ReturnType<typeof BottomSheetWrapper>;
|
|
6
|
+
export default BottomSheetWrapper;
|
|
7
|
+
//# sourceMappingURL=BottomSheetWrapper.test.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BottomSheetWrapper.test.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/primitives/BottomSheet/BottomSheetWrapper.test.svelte.ts"],"names":[],"mappings":"AAME,UAAU,KAAK;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAcH,QAAA,MAAM,kBAAkB,2CAAwC,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
|
|
@@ -42,8 +42,8 @@ describe("Breadcrumb Component Tests", () => {
|
|
|
42
42
|
|
|
43
43
|
test("First item shows icon", () => {
|
|
44
44
|
setupTest();
|
|
45
|
-
// First item has an icon
|
|
46
|
-
const icons = document.querySelectorAll("
|
|
45
|
+
// First item has an icon (HomeSolid SVG)
|
|
46
|
+
const icons = document.querySelectorAll("svg");
|
|
47
47
|
// Should have at least the home icon plus separator arrows
|
|
48
48
|
expect(icons.length).toBeGreaterThan(0);
|
|
49
49
|
});
|
|
@@ -51,9 +51,9 @@ describe("Breadcrumb Component Tests", () => {
|
|
|
51
51
|
test("Shows separator arrows between items", () => {
|
|
52
52
|
setupTest();
|
|
53
53
|
// Arrows appear between items (n-1 arrows for n items)
|
|
54
|
-
const
|
|
55
|
-
// 1 home icon + 2 arrows = 3
|
|
56
|
-
expect(
|
|
54
|
+
const svgs = document.querySelectorAll("svg");
|
|
55
|
+
// 1 home icon + 2 chevron arrows = 3 SVGs minimum
|
|
56
|
+
expect(svgs.length).toBeGreaterThanOrEqual(3);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
test("Last item is not a link", () => {
|
|
@@ -75,15 +75,14 @@ describe("Breadcrumb Component Tests", () => {
|
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
test("Dispatches click event when clicking breadcrumb", async () => {
|
|
78
|
-
const { user, component } = setupTest();
|
|
79
78
|
const clickSpy = vi.fn();
|
|
80
|
-
|
|
79
|
+
const { user } = setupTest({ onclick: clickSpy });
|
|
81
80
|
|
|
82
81
|
const homeLink = screen.getByText("Home").closest("a");
|
|
83
82
|
await user.click(homeLink);
|
|
84
83
|
|
|
85
84
|
expect(clickSpy).toHaveBeenCalled();
|
|
86
|
-
expect(clickSpy
|
|
85
|
+
expect(clickSpy).toHaveBeenCalledWith(sampleData[0]);
|
|
87
86
|
});
|
|
88
87
|
|
|
89
88
|
test("Last item has tertiary text color", () => {
|
|
@@ -95,13 +94,16 @@ describe("Breadcrumb Component Tests", () => {
|
|
|
95
94
|
test("Last item has default cursor", () => {
|
|
96
95
|
setupTest();
|
|
97
96
|
const lastItem = screen.getByText("Settings");
|
|
98
|
-
|
|
97
|
+
// Last item is a span, not a link, so it should not be clickable
|
|
98
|
+
expect(lastItem.tagName).toBe("SPAN");
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
test("Clickable items have pointer cursor", () => {
|
|
102
102
|
setupTest();
|
|
103
|
-
const
|
|
104
|
-
|
|
103
|
+
const homeLink = screen.getByText("Home").closest("a");
|
|
104
|
+
// Links are clickable elements
|
|
105
|
+
expect(homeLink).toBeInTheDocument();
|
|
106
|
+
expect(homeLink.tagName).toBe("A");
|
|
105
107
|
});
|
|
106
108
|
|
|
107
109
|
test("Has responsive text sizing", () => {
|
|
@@ -113,8 +115,8 @@ describe("Breadcrumb Component Tests", () => {
|
|
|
113
115
|
test("Renders with single item", () => {
|
|
114
116
|
render(Breadcrumb, { props: { data: [{ name: "Single", href: "/" }] } });
|
|
115
117
|
expect(screen.getByText("Single")).toBeInTheDocument();
|
|
116
|
-
// Single item
|
|
118
|
+
// Single item is both first and last, component renders it as span (last item)
|
|
117
119
|
const item = screen.getByText("Single");
|
|
118
|
-
expect(item.
|
|
120
|
+
expect(item.tagName).toBe("SPAN");
|
|
119
121
|
});
|
|
120
122
|
});
|
|
@@ -45,7 +45,11 @@
|
|
|
45
45
|
{#if index > 0}
|
|
46
46
|
<ChevronRightOutline class="rtl:rotate-180 w-3 h-3 text-gray-400 mx-1" />
|
|
47
47
|
{/if}
|
|
48
|
-
{#if index ===
|
|
48
|
+
{#if index === data.length - 1}
|
|
49
|
+
<span class={`ms-1 ${typography.smMuted} font-medium md:ms-2 max-w-48 truncate`} title={crumb.name}>
|
|
50
|
+
{crumb.name}
|
|
51
|
+
</span>
|
|
52
|
+
{:else if index === 0 && showHomeIcon}
|
|
49
53
|
<a
|
|
50
54
|
href={crumb.href}
|
|
51
55
|
onclick={() => handleClick(crumb)}
|
|
@@ -54,10 +58,6 @@
|
|
|
54
58
|
<HomeSolid class="w-3 h-3 me-2.5" />
|
|
55
59
|
{crumb.name}
|
|
56
60
|
</a>
|
|
57
|
-
{:else if index === data.length - 1}
|
|
58
|
-
<span class={`ms-1 ${typography.smMuted} font-medium md:ms-2 max-w-48 truncate`} title={crumb.name}>
|
|
59
|
-
{crumb.name}
|
|
60
|
-
</span>
|
|
61
61
|
{:else}
|
|
62
62
|
<a
|
|
63
63
|
href={crumb.href}
|
|
@@ -6,8 +6,12 @@ import Button from './Button.svelte';
|
|
|
6
6
|
function setupTest(args = {}) {
|
|
7
7
|
const user = userEvent.setup();
|
|
8
8
|
const onClick = vi.fn();
|
|
9
|
-
const { component } = render(Button, {
|
|
10
|
-
|
|
9
|
+
const { component } = render(Button, {
|
|
10
|
+
props: {
|
|
11
|
+
...args,
|
|
12
|
+
onclick: onClick
|
|
13
|
+
}
|
|
14
|
+
});
|
|
11
15
|
const button = screen.getByRole('button');
|
|
12
16
|
return {
|
|
13
17
|
user,
|
|
@@ -36,59 +40,62 @@ describe('Button Component Tests', () => {
|
|
|
36
40
|
expect(onClick).not.toHaveBeenCalled();
|
|
37
41
|
});
|
|
38
42
|
|
|
39
|
-
test('Renders with
|
|
40
|
-
const {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const afterIcon = button.querySelector('img.ml-2');
|
|
44
|
-
|
|
45
|
-
expect(beforeIcon).toBeInTheDocument();
|
|
46
|
-
expect(beforeIcon).toHaveAttribute('src', 'icon-before.png');
|
|
47
|
-
|
|
48
|
-
expect(afterIcon).toBeInTheDocument();
|
|
49
|
-
expect(afterIcon).toHaveAttribute('src', 'icon-after.png');
|
|
43
|
+
test('Renders with text content', () => {
|
|
44
|
+
const { container } = render(Button);
|
|
45
|
+
const button = container.querySelector('button');
|
|
46
|
+
expect(button).toBeInTheDocument();
|
|
50
47
|
});
|
|
51
48
|
|
|
52
|
-
test('Handles custom classes passed via
|
|
53
|
-
const { button } = setupTest({
|
|
49
|
+
test('Handles custom classes passed via class prop', () => {
|
|
50
|
+
const { button } = setupTest({ class: 'custom-class' });
|
|
54
51
|
expect(button).toHaveClass('custom-class');
|
|
55
52
|
});
|
|
56
53
|
});
|
|
57
54
|
|
|
58
55
|
describe('Button Variants', () => {
|
|
59
|
-
test('Default variant
|
|
56
|
+
test('Default variant has blue background', () => {
|
|
60
57
|
const { button } = setupTest();
|
|
61
|
-
expect(button).toHaveClass('
|
|
58
|
+
expect(button).toHaveClass('bg-blue-700');
|
|
62
59
|
});
|
|
63
60
|
|
|
64
61
|
test('Blue outline variant', () => {
|
|
65
|
-
const { button } = setupTest({ variant: '
|
|
66
|
-
expect(button).toHaveClass('
|
|
62
|
+
const { button } = setupTest({ variant: 'outline' });
|
|
63
|
+
expect(button).toHaveClass('text-blue-700');
|
|
64
|
+
expect(button).toHaveClass('border-blue-700');
|
|
67
65
|
});
|
|
68
66
|
|
|
69
|
-
test('Gray outline variant', () => {
|
|
70
|
-
const { button } = setupTest({ variant: '
|
|
71
|
-
expect(button).toHaveClass('
|
|
67
|
+
test('Gray outline variant (alternative)', () => {
|
|
68
|
+
const { button } = setupTest({ variant: 'alternative' });
|
|
69
|
+
expect(button).toHaveClass('text-gray-900');
|
|
70
|
+
expect(button).toHaveClass('border-gray-200');
|
|
72
71
|
});
|
|
73
72
|
|
|
74
73
|
test('Red solid variant', () => {
|
|
75
|
-
const { button } = setupTest({ variant: 'red
|
|
76
|
-
expect(button).toHaveClass('
|
|
74
|
+
const { button } = setupTest({ variant: 'red' });
|
|
75
|
+
expect(button).toHaveClass('bg-red-700');
|
|
77
76
|
});
|
|
78
77
|
|
|
79
78
|
test('Red outline variant', () => {
|
|
80
79
|
const { button } = setupTest({ variant: 'red-outline' });
|
|
81
|
-
expect(button).toHaveClass('
|
|
80
|
+
expect(button).toHaveClass('text-red-700');
|
|
81
|
+
expect(button).toHaveClass('border-red-700');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('Red text variant (ghost-red)', () => {
|
|
85
|
+
const { button } = setupTest({ variant: 'ghost-red' });
|
|
86
|
+
expect(button).toHaveClass('text-red-700');
|
|
87
|
+
expect(button).toHaveClass('bg-transparent');
|
|
82
88
|
});
|
|
83
89
|
|
|
84
|
-
test('
|
|
85
|
-
const { button } = setupTest({ variant: '
|
|
86
|
-
expect(button).toHaveClass('
|
|
90
|
+
test('Gray text variant (ghost)', () => {
|
|
91
|
+
const { button } = setupTest({ variant: 'ghost' });
|
|
92
|
+
expect(button).toHaveClass('text-gray-500');
|
|
93
|
+
expect(button).toHaveClass('bg-transparent');
|
|
87
94
|
});
|
|
88
95
|
|
|
89
|
-
test('
|
|
90
|
-
const { button } = setupTest({ variant: '
|
|
91
|
-
expect(button).toHaveClass('
|
|
96
|
+
test('Legacy variant names still work', () => {
|
|
97
|
+
const { button } = setupTest({ variant: 'blue-solid' });
|
|
98
|
+
expect(button).toHaveClass('bg-blue-700');
|
|
92
99
|
});
|
|
93
100
|
});
|
|
94
101
|
|
|
@@ -96,6 +103,8 @@ describe('Button Sizes', () => {
|
|
|
96
103
|
test('Full width size', () => {
|
|
97
104
|
const { button } = setupTest({ size: 'full' });
|
|
98
105
|
expect(button).toHaveClass('w-full');
|
|
106
|
+
expect(button).toHaveClass('px-5');
|
|
107
|
+
expect(button).toHaveClass('py-3');
|
|
99
108
|
});
|
|
100
109
|
|
|
101
110
|
test('Full width on mobile, auto on desktop', () => {
|
|
@@ -104,54 +113,44 @@ describe('Button Sizes', () => {
|
|
|
104
113
|
expect(button).toHaveClass('md:w-auto');
|
|
105
114
|
});
|
|
106
115
|
|
|
116
|
+
test('XL size', () => {
|
|
117
|
+
const { button } = setupTest({ size: 'xl' });
|
|
118
|
+
expect(button).toHaveClass('px-6');
|
|
119
|
+
expect(button).toHaveClass('py-3.5');
|
|
120
|
+
expect(button).toHaveClass('text-sm');
|
|
121
|
+
});
|
|
122
|
+
|
|
107
123
|
test('Large size', () => {
|
|
108
124
|
const { button } = setupTest({ size: 'lg' });
|
|
109
|
-
expect(button).toHaveClass('px-
|
|
125
|
+
expect(button).toHaveClass('px-5');
|
|
110
126
|
expect(button).toHaveClass('py-3');
|
|
127
|
+
expect(button).toHaveClass('text-sm');
|
|
111
128
|
});
|
|
112
129
|
|
|
113
|
-
test('Medium size', () => {
|
|
130
|
+
test('Medium size (default)', () => {
|
|
114
131
|
const { button } = setupTest({ size: 'md' });
|
|
115
|
-
expect(button).toHaveClass('px-
|
|
116
|
-
expect(button).toHaveClass('py-
|
|
132
|
+
expect(button).toHaveClass('px-4');
|
|
133
|
+
expect(button).toHaveClass('py-2.5');
|
|
134
|
+
expect(button).toHaveClass('text-sm');
|
|
117
135
|
});
|
|
118
136
|
|
|
119
137
|
test('Small size', () => {
|
|
120
138
|
const { button } = setupTest({ size: 'sm' });
|
|
121
|
-
expect(button).toHaveClass('
|
|
122
|
-
expect(button).toHaveClass('
|
|
139
|
+
expect(button).toHaveClass('px-3');
|
|
140
|
+
expect(button).toHaveClass('py-2');
|
|
141
|
+
expect(button).toHaveClass('text-sm');
|
|
123
142
|
});
|
|
124
143
|
|
|
125
144
|
test('Extra small size', () => {
|
|
126
145
|
const { button } = setupTest({ size: 'xs' });
|
|
146
|
+
expect(button).toHaveClass('px-3');
|
|
147
|
+
expect(button).toHaveClass('py-1.5');
|
|
127
148
|
expect(button).toHaveClass('text-xs');
|
|
128
149
|
});
|
|
129
150
|
|
|
130
|
-
test('Nav size', () => {
|
|
131
|
-
const { button } = setupTest({ size: 'nav' });
|
|
132
|
-
expect(button).toHaveClass('w-full');
|
|
133
|
-
});
|
|
134
|
-
|
|
135
151
|
test('Half width size', () => {
|
|
136
152
|
const { button } = setupTest({ size: 'half' });
|
|
137
|
-
expect(button
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
describe('Button Min Width', () => {
|
|
142
|
-
test('Small min width', () => {
|
|
143
|
-
const { button } = setupTest({ minWidth: 'sm' });
|
|
144
|
-
expect(button.className).toMatch(/min-w-\[100px\]/);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
test('Action min width', () => {
|
|
148
|
-
const { button } = setupTest({ minWidth: 'action' });
|
|
149
|
-
expect(button.className).toMatch(/min-w-\[150px\]/);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
test('Modal min width', () => {
|
|
153
|
-
const { button } = setupTest({ minWidth: 'modal' });
|
|
154
|
-
expect(button.className).toMatch(/min-w-\[130px\]/);
|
|
153
|
+
expect(button).toHaveClass('w-1/2');
|
|
155
154
|
});
|
|
156
155
|
});
|
|
157
156
|
|
|
@@ -168,7 +167,7 @@ describe('Button States', () => {
|
|
|
168
167
|
const { button, onClick } = setupTest({ success: true });
|
|
169
168
|
|
|
170
169
|
expect(button).toBeDisabled();
|
|
171
|
-
expect(button).toHaveClass('
|
|
170
|
+
expect(button).toHaveClass('bg-green-600');
|
|
172
171
|
await userEvent.click(button);
|
|
173
172
|
expect(onClick).not.toHaveBeenCalled();
|
|
174
173
|
|
|
@@ -177,13 +176,19 @@ describe('Button States', () => {
|
|
|
177
176
|
});
|
|
178
177
|
|
|
179
178
|
test('Active state for nav items', () => {
|
|
180
|
-
const { button } = setupTest({ active: true,
|
|
181
|
-
expect(button).toHaveClass('
|
|
179
|
+
const { button } = setupTest({ active: true, variant: 'nav' });
|
|
180
|
+
expect(button).toHaveClass('text-blue-600');
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test('Active state for toggle variant', () => {
|
|
184
|
+
const { button } = setupTest({ active: true, variant: 'toggle' });
|
|
185
|
+
expect(button).toHaveClass('bg-blue-600');
|
|
182
186
|
});
|
|
183
187
|
|
|
184
|
-
test('
|
|
185
|
-
const { button } = setupTest({
|
|
186
|
-
expect(button).toHaveClass('
|
|
188
|
+
test('Active state for ghost variant', () => {
|
|
189
|
+
const { button } = setupTest({ active: true, variant: 'ghost' });
|
|
190
|
+
expect(button).toHaveClass('text-blue-700');
|
|
191
|
+
expect(button).toHaveClass('bg-blue-50');
|
|
187
192
|
});
|
|
188
193
|
});
|
|
189
194
|
|
|
@@ -202,10 +207,17 @@ describe('Button as Link', () => {
|
|
|
202
207
|
});
|
|
203
208
|
});
|
|
204
209
|
|
|
205
|
-
describe('Button
|
|
206
|
-
test('
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
+
describe('Button with Trailing Content', () => {
|
|
211
|
+
test('Button with trailing content uses justify-between', () => {
|
|
212
|
+
const trailing = () => '→';
|
|
213
|
+
const { container } = render(Button, {
|
|
214
|
+
props: {
|
|
215
|
+
variant: 'menu-item',
|
|
216
|
+
children: () => 'Menu Item',
|
|
217
|
+
trailing,
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
const button = container.querySelector('button');
|
|
221
|
+
expect(button).toHaveClass('justify-between');
|
|
210
222
|
});
|
|
211
223
|
});
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/svelte';
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent, cleanup } from '@testing-library/svelte';
|
|
3
3
|
import ButtonSaveDemo from './ButtonSaveDemo.svelte';
|
|
4
4
|
|
|
5
5
|
describe('ButtonSaveDemo', () => {
|
|
6
|
+
// Clean up after each test
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
cleanup();
|
|
9
|
+
vi.useFakeTimers();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
vi.useRealTimers();
|
|
14
|
+
});
|
|
15
|
+
|
|
6
16
|
// Helper to get the Save button specifically (not the Reset button)
|
|
7
17
|
const getSaveButton = () => screen.getByRole('button', { name: /save|saving|saved/i });
|
|
8
18
|
|
|
@@ -45,4 +55,92 @@ describe('ButtonSaveDemo', () => {
|
|
|
45
55
|
expect(button).toHaveAttribute('disabled');
|
|
46
56
|
});
|
|
47
57
|
});
|
|
58
|
+
|
|
59
|
+
describe('success state', () => {
|
|
60
|
+
it('shows success state after timeout', async () => {
|
|
61
|
+
render(ButtonSaveDemo);
|
|
62
|
+
const button = getSaveButton();
|
|
63
|
+
|
|
64
|
+
await fireEvent.click(button);
|
|
65
|
+
|
|
66
|
+
// Advance timers past the 1000ms setTimeout
|
|
67
|
+
await vi.advanceTimersByTimeAsync(1100);
|
|
68
|
+
|
|
69
|
+
// Button should now be in success state (still disabled)
|
|
70
|
+
expect(button).toHaveAttribute('disabled');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('stays in success state after completion', async () => {
|
|
74
|
+
render(ButtonSaveDemo);
|
|
75
|
+
const button = getSaveButton();
|
|
76
|
+
|
|
77
|
+
await fireEvent.click(button);
|
|
78
|
+
await vi.advanceTimersByTimeAsync(1100);
|
|
79
|
+
|
|
80
|
+
// Button should remain disabled in success state
|
|
81
|
+
expect(button).toHaveAttribute('disabled');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('does not retrigger if already loading', async () => {
|
|
85
|
+
render(ButtonSaveDemo);
|
|
86
|
+
const button = getSaveButton();
|
|
87
|
+
|
|
88
|
+
// First click
|
|
89
|
+
await fireEvent.click(button);
|
|
90
|
+
|
|
91
|
+
// Second click while loading - should be ignored
|
|
92
|
+
await fireEvent.click(button);
|
|
93
|
+
|
|
94
|
+
// Should still be in loading state
|
|
95
|
+
expect(button).toHaveAttribute('disabled');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('does not retrigger if already in success state', async () => {
|
|
99
|
+
render(ButtonSaveDemo);
|
|
100
|
+
const button = getSaveButton();
|
|
101
|
+
|
|
102
|
+
await fireEvent.click(button);
|
|
103
|
+
await vi.advanceTimersByTimeAsync(1100);
|
|
104
|
+
|
|
105
|
+
// Click while in success state - should be ignored
|
|
106
|
+
await fireEvent.click(button);
|
|
107
|
+
|
|
108
|
+
expect(button).toHaveAttribute('disabled');
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe('reset functionality', () => {
|
|
113
|
+
it('reset button clears success state', async () => {
|
|
114
|
+
render(ButtonSaveDemo);
|
|
115
|
+
const saveButton = getSaveButton();
|
|
116
|
+
const resetButton = screen.getByText(/Reset/);
|
|
117
|
+
|
|
118
|
+
// Trigger save and complete
|
|
119
|
+
await fireEvent.click(saveButton);
|
|
120
|
+
await vi.advanceTimersByTimeAsync(1100);
|
|
121
|
+
|
|
122
|
+
// Click reset
|
|
123
|
+
await fireEvent.click(resetButton);
|
|
124
|
+
|
|
125
|
+
// Save button should be enabled again
|
|
126
|
+
expect(saveButton).not.toHaveAttribute('disabled');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('allows re-save after reset', async () => {
|
|
130
|
+
render(ButtonSaveDemo);
|
|
131
|
+
const saveButton = getSaveButton();
|
|
132
|
+
const resetButton = screen.getByText(/Reset/);
|
|
133
|
+
|
|
134
|
+
// First save cycle
|
|
135
|
+
await fireEvent.click(saveButton);
|
|
136
|
+
await vi.advanceTimersByTimeAsync(1100);
|
|
137
|
+
|
|
138
|
+
// Reset
|
|
139
|
+
await fireEvent.click(resetButton);
|
|
140
|
+
|
|
141
|
+
// Second save should work
|
|
142
|
+
await fireEvent.click(saveButton);
|
|
143
|
+
expect(saveButton).toHaveAttribute('disabled');
|
|
144
|
+
});
|
|
145
|
+
});
|
|
48
146
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonVariantShowcase.spec.d.ts","sourceRoot":"","sources":["../../../src/lib/primitives/Button/ButtonVariantShowcase.spec.js"],"names":[],"mappings":""}
|