@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,145 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/svelte';
|
|
2
|
+
import { expect, describe, test } from 'vitest';
|
|
3
|
+
import PageLayout from './PageLayout.svelte';
|
|
4
|
+
|
|
5
|
+
describe('PageLayout Component', () => {
|
|
6
|
+
test('renders a nav element when showHeader=true', () => {
|
|
7
|
+
const { container } = render(PageLayout, { props: { showHeader: true, title: 'Test' } });
|
|
8
|
+
expect(container.querySelector('nav')).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('does not render nav when showHeader=false', () => {
|
|
12
|
+
const { container } = render(PageLayout, { props: { showHeader: false } });
|
|
13
|
+
expect(container.querySelector('nav')).not.toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('nav has pt-4 px-4 classes', () => {
|
|
17
|
+
const { container } = render(PageLayout, { props: { showHeader: true, title: 'Test' } });
|
|
18
|
+
const nav = container.querySelector('nav');
|
|
19
|
+
expect(nav).toHaveClass('pt-4');
|
|
20
|
+
expect(nav).toHaveClass('px-4');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('PageLayout Content Area', () => {
|
|
25
|
+
test('has content div with padding classes', () => {
|
|
26
|
+
const { container } = render(PageLayout);
|
|
27
|
+
const contentDiv = container.querySelector('div.px-4');
|
|
28
|
+
expect(contentDiv).toBeInTheDocument();
|
|
29
|
+
expect(contentDiv).toHaveClass('pt-4');
|
|
30
|
+
expect(contentDiv).toHaveClass('pb-20');
|
|
31
|
+
expect(contentDiv).toHaveClass('md:pb-6');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('applies custom className to content', () => {
|
|
35
|
+
const { container } = render(PageLayout, { props: { className: 'custom-layout' } });
|
|
36
|
+
const contentDiv = container.querySelector('div.custom-layout');
|
|
37
|
+
expect(contentDiv).toBeInTheDocument();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('PageLayout Variant', () => {
|
|
42
|
+
test('default variant renders children directly', () => {
|
|
43
|
+
const { container } = render(PageLayout, { props: { variant: 'default' } });
|
|
44
|
+
// Should not have a Card wrapper
|
|
45
|
+
const card = container.querySelector('.bg-white.dark\\:bg-gray-800');
|
|
46
|
+
expect(card).not.toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('card variant wraps content in Card', () => {
|
|
50
|
+
const { container } = render(PageLayout, { props: { variant: 'card' } });
|
|
51
|
+
// Card should be rendered with white bg
|
|
52
|
+
const cardWrapper = container.querySelector('.bg-white');
|
|
53
|
+
expect(cardWrapper).toBeInTheDocument();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('PageLayout MaxWidth', () => {
|
|
58
|
+
// Note: maxWidth prop is passed to Card but Card uses 'class' not 'className'
|
|
59
|
+
// This is a known issue - tests verify component accepts the prop
|
|
60
|
+
test('accepts maxWidth prop', () => {
|
|
61
|
+
const { container } = render(PageLayout, { props: { variant: 'card', maxWidth: 'max-w-4xl' } });
|
|
62
|
+
expect(container).toBeInTheDocument();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('PageLayout Header', () => {
|
|
67
|
+
test('header has flex layout', () => {
|
|
68
|
+
const { container } = render(PageLayout, { props: { showHeader: true, title: 'Test' } });
|
|
69
|
+
const flexDiv = container.querySelector('nav > div.flex');
|
|
70
|
+
expect(flexDiv).toBeInTheDocument();
|
|
71
|
+
expect(flexDiv).toHaveClass('flex-col');
|
|
72
|
+
expect(flexDiv).toHaveClass('sm:flex-row');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('header has responsive alignment', () => {
|
|
76
|
+
const { container } = render(PageLayout, { props: { showHeader: true, title: 'Test' } });
|
|
77
|
+
const flexDiv = container.querySelector('nav > div.flex');
|
|
78
|
+
expect(flexDiv).toHaveClass('sm:items-start');
|
|
79
|
+
expect(flexDiv).toHaveClass('sm:justify-between');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('header has gap-4', () => {
|
|
83
|
+
const { container } = render(PageLayout, { props: { showHeader: true, title: 'Test' } });
|
|
84
|
+
const flexDiv = container.querySelector('nav > div.flex');
|
|
85
|
+
expect(flexDiv).toHaveClass('gap-4');
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('PageLayout Title', () => {
|
|
90
|
+
test('title is passed to Breadcrumb', () => {
|
|
91
|
+
const { container } = render(PageLayout, { props: { title: 'Dashboard', showHeader: true } });
|
|
92
|
+
// Breadcrumb renders the title
|
|
93
|
+
expect(container).toBeInTheDocument();
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe('PageLayout Subtitle', () => {
|
|
98
|
+
test('subtitle is passed to Breadcrumb', () => {
|
|
99
|
+
const { container } = render(PageLayout, {
|
|
100
|
+
props: { title: 'Dashboard', subtitle: 'Welcome back', showHeader: true }
|
|
101
|
+
});
|
|
102
|
+
expect(container).toBeInTheDocument();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('PageLayout Breadcrumb', () => {
|
|
107
|
+
test('empty breadcrumb array works', () => {
|
|
108
|
+
const { container } = render(PageLayout, { props: { breadcrumb: [], showHeader: true } });
|
|
109
|
+
expect(container).toBeInTheDocument();
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('PageLayout Combinations', () => {
|
|
114
|
+
test('showHeader with title', () => {
|
|
115
|
+
const { container } = render(PageLayout, {
|
|
116
|
+
props: { showHeader: true, title: 'Settings' }
|
|
117
|
+
});
|
|
118
|
+
expect(container.querySelector('nav')).toBeInTheDocument();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('card variant with maxWidth', () => {
|
|
122
|
+
const { container } = render(PageLayout, {
|
|
123
|
+
props: { variant: 'card', maxWidth: 'max-w-3xl' }
|
|
124
|
+
});
|
|
125
|
+
// Card renders with bg-white
|
|
126
|
+
expect(container.querySelector('.bg-white')).toBeInTheDocument();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('all props together', () => {
|
|
130
|
+
const { container } = render(PageLayout, {
|
|
131
|
+
props: {
|
|
132
|
+
showHeader: true,
|
|
133
|
+
title: 'Profile',
|
|
134
|
+
subtitle: 'Edit your details',
|
|
135
|
+
breadcrumb: [{ label: 'Home', href: '/' }],
|
|
136
|
+
variant: 'card',
|
|
137
|
+
maxWidth: 'max-w-2xl',
|
|
138
|
+
className: 'custom-page'
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
expect(container.querySelector('nav')).toBeInTheDocument();
|
|
142
|
+
expect(container.querySelector('.bg-white')).toBeInTheDocument();
|
|
143
|
+
expect(container.querySelector('.custom-page')).toBeInTheDocument();
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -5,7 +5,10 @@ import PageLoader from "./PageLoader.svelte";
|
|
|
5
5
|
describe("PageLoader Component Tests", () => {
|
|
6
6
|
test("Shows spinner when loading", () => {
|
|
7
7
|
render(PageLoader, { props: { isLoading: true } });
|
|
8
|
-
|
|
8
|
+
// The spinner SVG has aria-hidden="true", so we query with hidden: true
|
|
9
|
+
expect(screen.getByRole("status", { hidden: true })).toBeInTheDocument();
|
|
10
|
+
// Or verify via the accessible loading text
|
|
11
|
+
expect(screen.getByText("Loading...")).toBeInTheDocument();
|
|
9
12
|
});
|
|
10
13
|
|
|
11
14
|
test("Shows error alert when error is set", () => {
|
|
@@ -29,7 +32,7 @@ describe("PageLoader Component Tests", () => {
|
|
|
29
32
|
|
|
30
33
|
test("Does not show spinner when not loading", () => {
|
|
31
34
|
render(PageLoader, { props: { isLoading: false } });
|
|
32
|
-
expect(screen.queryByRole("status")).not.toBeInTheDocument();
|
|
35
|
+
expect(screen.queryByRole("status", { hidden: true })).not.toBeInTheDocument();
|
|
33
36
|
});
|
|
34
37
|
|
|
35
38
|
test("Does not show error when no error", () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionHeader.spec.d.ts","sourceRoot":"","sources":["../../../src/lib/patterns/page/SectionHeader.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/svelte';
|
|
2
|
+
import { expect, describe, test } from 'vitest';
|
|
3
|
+
import SectionHeader from './SectionHeader.svelte';
|
|
4
|
+
|
|
5
|
+
describe('SectionHeader Component', () => {
|
|
6
|
+
test('renders a wrapper div', () => {
|
|
7
|
+
const { container } = render(SectionHeader);
|
|
8
|
+
expect(container.querySelector('div')).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('applies custom className', () => {
|
|
12
|
+
const { container } = render(SectionHeader, { props: { class: 'custom-section' } });
|
|
13
|
+
const wrapper = container.querySelector('div');
|
|
14
|
+
expect(wrapper).toHaveClass('custom-section');
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('SectionHeader Title', () => {
|
|
19
|
+
test('no title renders no h2', () => {
|
|
20
|
+
const { container } = render(SectionHeader);
|
|
21
|
+
expect(container.querySelector('h2')).not.toBeInTheDocument();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('title prop renders h2', () => {
|
|
25
|
+
render(SectionHeader, { props: { title: 'Recent Activity' } });
|
|
26
|
+
expect(screen.getByText('Recent Activity')).toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('title is in h2 element', () => {
|
|
30
|
+
const { container } = render(SectionHeader, { props: { title: 'Orders' } });
|
|
31
|
+
const h2 = container.querySelector('h2');
|
|
32
|
+
expect(h2).toBeInTheDocument();
|
|
33
|
+
expect(h2).toHaveTextContent('Orders');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('SectionHeader Description', () => {
|
|
38
|
+
test('no description renders no p', () => {
|
|
39
|
+
const { container } = render(SectionHeader);
|
|
40
|
+
expect(container.querySelector('p')).not.toBeInTheDocument();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('description prop renders p', () => {
|
|
44
|
+
render(SectionHeader, { props: { description: 'View all recent orders' } });
|
|
45
|
+
expect(screen.getByText('View all recent orders')).toBeInTheDocument();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('description p has mt-1 margin', () => {
|
|
49
|
+
const { container } = render(SectionHeader, { props: { description: 'Test desc' } });
|
|
50
|
+
const p = container.querySelector('p');
|
|
51
|
+
expect(p).toHaveClass('mt-1');
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('SectionHeader Count', () => {
|
|
56
|
+
test('no count by default', () => {
|
|
57
|
+
const { container } = render(SectionHeader, { props: { title: 'Items' } });
|
|
58
|
+
const span = container.querySelector('span');
|
|
59
|
+
expect(span).not.toBeInTheDocument();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('count=null renders no badge', () => {
|
|
63
|
+
const { container } = render(SectionHeader, { props: { title: 'Items', count: null } });
|
|
64
|
+
const span = container.querySelector('span');
|
|
65
|
+
expect(span).not.toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('count prop renders badge', () => {
|
|
69
|
+
render(SectionHeader, { props: { title: 'Items', count: 42 } });
|
|
70
|
+
expect(screen.getByText('42')).toBeInTheDocument();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('count=0 still renders badge', () => {
|
|
74
|
+
render(SectionHeader, { props: { title: 'Items', count: 0 } });
|
|
75
|
+
expect(screen.getByText('0')).toBeInTheDocument();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('count badge has styling classes', () => {
|
|
79
|
+
const { container } = render(SectionHeader, { props: { title: 'Test', count: 5 } });
|
|
80
|
+
const badge = container.querySelector('span');
|
|
81
|
+
expect(badge).toHaveClass('inline-flex');
|
|
82
|
+
expect(badge).toHaveClass('items-center');
|
|
83
|
+
expect(badge).toHaveClass('justify-center');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('count badge has bg-gray-100', () => {
|
|
87
|
+
const { container } = render(SectionHeader, { props: { title: 'Test', count: 10 } });
|
|
88
|
+
const badge = container.querySelector('span');
|
|
89
|
+
expect(badge).toHaveClass('bg-gray-100');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('count badge has rounded-full', () => {
|
|
93
|
+
const { container } = render(SectionHeader, { props: { title: 'Test', count: 10 } });
|
|
94
|
+
const badge = container.querySelector('span');
|
|
95
|
+
expect(badge).toHaveClass('rounded-full');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('count badge has dark mode bg', () => {
|
|
99
|
+
const { container } = render(SectionHeader, { props: { title: 'Test', count: 10 } });
|
|
100
|
+
const badge = container.querySelector('span');
|
|
101
|
+
expect(badge).toHaveClass('dark:bg-gray-700');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('count badge has padding', () => {
|
|
105
|
+
const { container } = render(SectionHeader, { props: { title: 'Test', count: 10 } });
|
|
106
|
+
const badge = container.querySelector('span');
|
|
107
|
+
expect(badge).toHaveClass('px-2');
|
|
108
|
+
expect(badge).toHaveClass('py-0.5');
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe('SectionHeader Divider', () => {
|
|
113
|
+
test('no divider by default', () => {
|
|
114
|
+
const { container } = render(SectionHeader);
|
|
115
|
+
expect(container.querySelector('hr')).not.toBeInTheDocument();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('divider=true shows hr', () => {
|
|
119
|
+
const { container } = render(SectionHeader, { props: { divider: true } });
|
|
120
|
+
expect(container.querySelector('hr')).toBeInTheDocument();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('divider=false hides hr', () => {
|
|
124
|
+
const { container } = render(SectionHeader, { props: { divider: false } });
|
|
125
|
+
expect(container.querySelector('hr')).not.toBeInTheDocument();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('divider has border-gray-200', () => {
|
|
129
|
+
const { container } = render(SectionHeader, { props: { divider: true } });
|
|
130
|
+
const hr = container.querySelector('hr');
|
|
131
|
+
expect(hr).toHaveClass('border-gray-200');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('divider has dark mode class', () => {
|
|
135
|
+
const { container } = render(SectionHeader, { props: { divider: true } });
|
|
136
|
+
const hr = container.querySelector('hr');
|
|
137
|
+
expect(hr).toHaveClass('dark:border-gray-700');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('divider has mb-4 margin', () => {
|
|
141
|
+
const { container } = render(SectionHeader, { props: { divider: true } });
|
|
142
|
+
const hr = container.querySelector('hr');
|
|
143
|
+
expect(hr).toHaveClass('mb-4');
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('SectionHeader Layout', () => {
|
|
148
|
+
test('has flex container for title and count', () => {
|
|
149
|
+
const { container } = render(SectionHeader, { props: { title: 'Test' } });
|
|
150
|
+
const flexDiv = container.querySelector('div.flex.items-center.justify-between');
|
|
151
|
+
expect(flexDiv).toBeInTheDocument();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test('flex container has gap-4', () => {
|
|
155
|
+
const { container } = render(SectionHeader, { props: { title: 'Test' } });
|
|
156
|
+
const flexDiv = container.querySelector('div.flex.items-center.justify-between');
|
|
157
|
+
expect(flexDiv).toHaveClass('gap-4');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test('title and count are in left flex group', () => {
|
|
161
|
+
const { container } = render(SectionHeader, { props: { title: 'Items', count: 5 } });
|
|
162
|
+
const leftGroup = container.querySelector('div.flex.items-center.gap-2');
|
|
163
|
+
expect(leftGroup).toBeInTheDocument();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
describe('SectionHeader Combinations', () => {
|
|
168
|
+
test('title and description', () => {
|
|
169
|
+
render(SectionHeader, { props: { title: 'Products', description: 'All available products' } });
|
|
170
|
+
expect(screen.getByText('Products')).toBeInTheDocument();
|
|
171
|
+
expect(screen.getByText('All available products')).toBeInTheDocument();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test('title and count', () => {
|
|
175
|
+
render(SectionHeader, { props: { title: 'Users', count: 150 } });
|
|
176
|
+
expect(screen.getByText('Users')).toBeInTheDocument();
|
|
177
|
+
expect(screen.getByText('150')).toBeInTheDocument();
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test('all props together', () => {
|
|
181
|
+
const { container } = render(SectionHeader, {
|
|
182
|
+
props: {
|
|
183
|
+
title: 'Orders',
|
|
184
|
+
description: 'View all orders',
|
|
185
|
+
count: 25,
|
|
186
|
+
divider: true,
|
|
187
|
+
class: 'mt-6'
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const wrapper = container.firstElementChild;
|
|
191
|
+
expect(wrapper).toHaveClass('mt-6');
|
|
192
|
+
expect(container.querySelector('hr')).toBeInTheDocument();
|
|
193
|
+
expect(screen.getByText('Orders')).toBeInTheDocument();
|
|
194
|
+
expect(screen.getByText('View all orders')).toBeInTheDocument();
|
|
195
|
+
expect(screen.getByText('25')).toBeInTheDocument();
|
|
196
|
+
});
|
|
197
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badges.spec.d.ts","sourceRoot":"","sources":["../../src/lib/presets/badges.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
ROLE_BADGE_VARIANTS,
|
|
4
|
+
ENTITY_BADGE_VARIANTS,
|
|
5
|
+
STATUS_BADGE_VARIANTS,
|
|
6
|
+
getRoleBadgeVariant,
|
|
7
|
+
getEntityBadgeVariant,
|
|
8
|
+
getStatusBadgeVariant,
|
|
9
|
+
} from './badges.js';
|
|
10
|
+
|
|
11
|
+
describe('Role Badge Variants', () => {
|
|
12
|
+
it('maps Host to red', () => {
|
|
13
|
+
expect(ROLE_BADGE_VARIANTS.Host).toBe('red');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('maps Headliner to purple', () => {
|
|
17
|
+
expect(ROLE_BADGE_VARIANTS.Headliner).toBe('purple');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('maps Feature to blue', () => {
|
|
21
|
+
expect(ROLE_BADGE_VARIANTS.Feature).toBe('blue');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('maps Special Guest to green', () => {
|
|
25
|
+
expect(ROLE_BADGE_VARIANTS['Special Guest']).toBe('green');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('maps Opener to orange', () => {
|
|
29
|
+
expect(ROLE_BADGE_VARIANTS.Opener).toBe('orange');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('maps Guest to gray', () => {
|
|
33
|
+
expect(ROLE_BADGE_VARIANTS.Guest).toBe('gray');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('maps Teacher to yellow', () => {
|
|
37
|
+
expect(ROLE_BADGE_VARIANTS.Teacher).toBe('yellow');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('maps Assistant to indigo', () => {
|
|
41
|
+
expect(ROLE_BADGE_VARIANTS.Assistant).toBe('indigo');
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('Entity Badge Variants', () => {
|
|
46
|
+
it('maps event to blue', () => {
|
|
47
|
+
expect(ENTITY_BADGE_VARIANTS.event).toBe('blue');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('maps venue to green', () => {
|
|
51
|
+
expect(ENTITY_BADGE_VARIANTS.venue).toBe('green');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('maps user to purple', () => {
|
|
55
|
+
expect(ENTITY_BADGE_VARIANTS.user).toBe('purple');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('maps order to orange', () => {
|
|
59
|
+
expect(ENTITY_BADGE_VARIANTS.order).toBe('orange');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('maps performer to pink', () => {
|
|
63
|
+
expect(ENTITY_BADGE_VARIANTS.performer).toBe('pink');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('Status Badge Variants', () => {
|
|
68
|
+
describe('Success States', () => {
|
|
69
|
+
const successStatuses = [
|
|
70
|
+
'Completed', 'Active', 'Confirmed', 'On Sale',
|
|
71
|
+
'Live', 'Enabled', 'Yes', 'Redeemed', 'Online'
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
successStatuses.forEach(status => {
|
|
75
|
+
it(`maps ${status} to success`, () => {
|
|
76
|
+
expect(STATUS_BADGE_VARIANTS[status]).toBe('success');
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('Warning States', () => {
|
|
82
|
+
const warningStatuses = [
|
|
83
|
+
'Pending', 'Scheduled', 'Paused', 'Ended',
|
|
84
|
+
'Refunded', 'Partially refunded', 'Pinned', 'Usage Limit Reached'
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
warningStatuses.forEach(status => {
|
|
88
|
+
it(`maps ${status} to warning`, () => {
|
|
89
|
+
expect(STATUS_BADGE_VARIANTS[status]).toBe('warning');
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('Error States', () => {
|
|
95
|
+
const errorStatuses = [
|
|
96
|
+
'Cancelled', 'Canceled', 'Declined', 'No show',
|
|
97
|
+
'Expired', 'Sales closed'
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
errorStatuses.forEach(status => {
|
|
101
|
+
it(`maps ${status} to error`, () => {
|
|
102
|
+
expect(STATUS_BADGE_VARIANTS[status]).toBe('error');
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('Info States', () => {
|
|
108
|
+
it('maps In Progress to info', () => {
|
|
109
|
+
expect(STATUS_BADGE_VARIANTS['In Progress']).toBe('info');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('maps Invited to info', () => {
|
|
113
|
+
expect(STATUS_BADGE_VARIANTS.Invited).toBe('info');
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe('Neutral States', () => {
|
|
118
|
+
const neutralStatuses = ['Draft', 'Offline', 'Disabled', 'No'];
|
|
119
|
+
|
|
120
|
+
neutralStatuses.forEach(status => {
|
|
121
|
+
it(`maps ${status} to neutral`, () => {
|
|
122
|
+
expect(STATUS_BADGE_VARIANTS[status]).toBe('neutral');
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe('getRoleBadgeVariant', () => {
|
|
129
|
+
it('returns correct variant for known role', () => {
|
|
130
|
+
expect(getRoleBadgeVariant('Host')).toBe('red');
|
|
131
|
+
expect(getRoleBadgeVariant('Headliner')).toBe('purple');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('returns gray for unknown role', () => {
|
|
135
|
+
expect(getRoleBadgeVariant('Unknown')).toBe('gray');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('returns gray for undefined role', () => {
|
|
139
|
+
expect(getRoleBadgeVariant(undefined)).toBe('gray');
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('getEntityBadgeVariant', () => {
|
|
144
|
+
it('returns correct variant for known entity', () => {
|
|
145
|
+
expect(getEntityBadgeVariant('event')).toBe('blue');
|
|
146
|
+
expect(getEntityBadgeVariant('venue')).toBe('green');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('returns gray for unknown entity', () => {
|
|
150
|
+
expect(getEntityBadgeVariant('unknown')).toBe('gray');
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('returns gray for undefined entity', () => {
|
|
154
|
+
expect(getEntityBadgeVariant(undefined)).toBe('gray');
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe('getStatusBadgeVariant', () => {
|
|
159
|
+
it('returns correct variant for known status', () => {
|
|
160
|
+
expect(getStatusBadgeVariant('Completed')).toBe('success');
|
|
161
|
+
expect(getStatusBadgeVariant('Pending')).toBe('warning');
|
|
162
|
+
expect(getStatusBadgeVariant('Cancelled')).toBe('error');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('returns neutral for unknown status', () => {
|
|
166
|
+
expect(getStatusBadgeVariant('Unknown')).toBe('neutral');
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('returns neutral for undefined status', () => {
|
|
170
|
+
expect(getStatusBadgeVariant(undefined)).toBe('neutral');
|
|
171
|
+
});
|
|
172
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buttons.spec.d.ts","sourceRoot":"","sources":["../../src/lib/presets/buttons.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { BUTTON_PRESETS, ICON_BUTTON_PRESETS } from './buttons.js';
|
|
3
|
+
|
|
4
|
+
describe('Button Presets', () => {
|
|
5
|
+
describe('save preset', () => {
|
|
6
|
+
it('has default variant', () => {
|
|
7
|
+
expect(BUTTON_PRESETS.save.variant).toBe('default');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('has submit type', () => {
|
|
11
|
+
expect(BUTTON_PRESETS.save.type).toBe('submit');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('cancel preset', () => {
|
|
16
|
+
it('has alternative variant', () => {
|
|
17
|
+
expect(BUTTON_PRESETS.cancel.variant).toBe('alternative');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('has button type', () => {
|
|
21
|
+
expect(BUTTON_PRESETS.cancel.type).toBe('button');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('delete preset', () => {
|
|
26
|
+
it('has red variant', () => {
|
|
27
|
+
expect(BUTTON_PRESETS.delete.variant).toBe('red');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('has button type', () => {
|
|
31
|
+
expect(BUTTON_PRESETS.delete.type).toBe('button');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('submit preset', () => {
|
|
36
|
+
it('has default variant like save', () => {
|
|
37
|
+
expect(BUTTON_PRESETS.submit.variant).toBe('default');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('has submit type', () => {
|
|
41
|
+
expect(BUTTON_PRESETS.submit.type).toBe('submit');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('is an alias for save', () => {
|
|
45
|
+
expect(BUTTON_PRESETS.submit.variant).toBe(BUTTON_PRESETS.save.variant);
|
|
46
|
+
expect(BUTTON_PRESETS.submit.type).toBe(BUTTON_PRESETS.save.type);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('secondary preset', () => {
|
|
51
|
+
it('has light variant', () => {
|
|
52
|
+
expect(BUTTON_PRESETS.secondary.variant).toBe('light');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('has button type', () => {
|
|
56
|
+
expect(BUTTON_PRESETS.secondary.type).toBe('button');
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('outline preset', () => {
|
|
61
|
+
it('has outline variant', () => {
|
|
62
|
+
expect(BUTTON_PRESETS.outline.variant).toBe('outline');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('has button type', () => {
|
|
66
|
+
expect(BUTTON_PRESETS.outline.type).toBe('button');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('ghost preset', () => {
|
|
71
|
+
it('has ghost variant', () => {
|
|
72
|
+
expect(BUTTON_PRESETS.ghost.variant).toBe('ghost');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('has button type', () => {
|
|
76
|
+
expect(BUTTON_PRESETS.ghost.type).toBe('button');
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('Icon Button Presets', () => {
|
|
82
|
+
describe('default preset', () => {
|
|
83
|
+
it('has ghost variant', () => {
|
|
84
|
+
expect(ICON_BUTTON_PRESETS.default.variant).toBe('ghost');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('has sm size', () => {
|
|
88
|
+
expect(ICON_BUTTON_PRESETS.default.size).toBe('sm');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('has padding className', () => {
|
|
92
|
+
expect(ICON_BUTTON_PRESETS.default.className).toBe('p-2');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('destructive preset', () => {
|
|
97
|
+
it('has ghost variant', () => {
|
|
98
|
+
expect(ICON_BUTTON_PRESETS.destructive.variant).toBe('ghost');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('has sm size', () => {
|
|
102
|
+
expect(ICON_BUTTON_PRESETS.destructive.size).toBe('sm');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('has red color classes', () => {
|
|
106
|
+
expect(ICON_BUTTON_PRESETS.destructive.className).toContain('text-red-600');
|
|
107
|
+
expect(ICON_BUTTON_PRESETS.destructive.className).toContain('hover:bg-red-100');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('has dark mode red classes', () => {
|
|
111
|
+
expect(ICON_BUTTON_PRESETS.destructive.className).toContain('dark:text-red-400');
|
|
112
|
+
expect(ICON_BUTTON_PRESETS.destructive.className).toContain('dark:hover:bg-red-900');
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe('Preset Structure', () => {
|
|
118
|
+
it('all presets have variant property', () => {
|
|
119
|
+
Object.values(BUTTON_PRESETS).forEach(preset => {
|
|
120
|
+
expect(preset).toHaveProperty('variant');
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('all presets have type property', () => {
|
|
125
|
+
Object.values(BUTTON_PRESETS).forEach(preset => {
|
|
126
|
+
expect(preset).toHaveProperty('type');
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('all icon presets have size property', () => {
|
|
131
|
+
Object.values(ICON_BUTTON_PRESETS).forEach(preset => {
|
|
132
|
+
expect(preset).toHaveProperty('size');
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|