@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,153 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/svelte';
|
|
2
|
+
import { expect, describe, test } from 'vitest';
|
|
3
|
+
import FormSection from './FormSection.svelte';
|
|
4
|
+
|
|
5
|
+
describe('FormSection Component', () => {
|
|
6
|
+
test('renders a section element', () => {
|
|
7
|
+
const { container } = render(FormSection);
|
|
8
|
+
expect(container.querySelector('section')).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('has space-y-4 class', () => {
|
|
12
|
+
const { container } = render(FormSection);
|
|
13
|
+
const section = container.querySelector('section');
|
|
14
|
+
expect(section).toHaveClass('space-y-4');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('applies custom className', () => {
|
|
18
|
+
const { container } = render(FormSection, { props: { class: 'custom-section' } });
|
|
19
|
+
const section = container.querySelector('section');
|
|
20
|
+
expect(section).toHaveClass('custom-section');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('FormSection Title', () => {
|
|
25
|
+
test('no title renders no h3', () => {
|
|
26
|
+
const { container } = render(FormSection);
|
|
27
|
+
expect(container.querySelector('h3')).not.toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('title prop renders h3', () => {
|
|
31
|
+
render(FormSection, { props: { title: 'Personal Info' } });
|
|
32
|
+
expect(screen.getByText('Personal Info')).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('title is in h3 element', () => {
|
|
36
|
+
const { container } = render(FormSection, { props: { title: 'Contact' } });
|
|
37
|
+
const h3 = container.querySelector('h3');
|
|
38
|
+
expect(h3).toBeInTheDocument();
|
|
39
|
+
expect(h3).toHaveTextContent('Contact');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('FormSection Description', () => {
|
|
44
|
+
test('no description renders no p', () => {
|
|
45
|
+
const { container } = render(FormSection);
|
|
46
|
+
expect(container.querySelector('p')).not.toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('description prop renders p', () => {
|
|
50
|
+
render(FormSection, { props: { description: 'Enter your details' } });
|
|
51
|
+
expect(screen.getByText('Enter your details')).toBeInTheDocument();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('description is in p element', () => {
|
|
55
|
+
const { container } = render(FormSection, { props: { description: 'Fill the form' } });
|
|
56
|
+
const p = container.querySelector('p');
|
|
57
|
+
expect(p).toBeInTheDocument();
|
|
58
|
+
expect(p).toHaveTextContent('Fill the form');
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('FormSection Header Area', () => {
|
|
63
|
+
test('no header when no title or description', () => {
|
|
64
|
+
const { container } = render(FormSection);
|
|
65
|
+
const headerDiv = container.querySelector('section > div.space-y-1');
|
|
66
|
+
expect(headerDiv).not.toBeInTheDocument();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('header appears when title provided', () => {
|
|
70
|
+
const { container } = render(FormSection, { props: { title: 'Title' } });
|
|
71
|
+
const headerDiv = container.querySelector('section > div.space-y-1');
|
|
72
|
+
expect(headerDiv).toBeInTheDocument();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('header appears when description provided', () => {
|
|
76
|
+
const { container } = render(FormSection, { props: { description: 'Desc' } });
|
|
77
|
+
const headerDiv = container.querySelector('section > div.space-y-1');
|
|
78
|
+
expect(headerDiv).toBeInTheDocument();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('header shows both title and description', () => {
|
|
82
|
+
const { container } = render(FormSection, { props: { title: 'My Title', description: 'My Desc' } });
|
|
83
|
+
expect(screen.getByText('My Title')).toBeInTheDocument();
|
|
84
|
+
expect(screen.getByText('My Desc')).toBeInTheDocument();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('FormSection Divider', () => {
|
|
89
|
+
test('no divider by default', () => {
|
|
90
|
+
const { container } = render(FormSection);
|
|
91
|
+
expect(container.querySelector('hr')).not.toBeInTheDocument();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('divider=true shows hr', () => {
|
|
95
|
+
const { container } = render(FormSection, { props: { divider: true } });
|
|
96
|
+
expect(container.querySelector('hr')).toBeInTheDocument();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('divider=false hides hr', () => {
|
|
100
|
+
const { container } = render(FormSection, { props: { divider: false } });
|
|
101
|
+
expect(container.querySelector('hr')).not.toBeInTheDocument();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('divider has border-gray-200', () => {
|
|
105
|
+
const { container } = render(FormSection, { props: { divider: true } });
|
|
106
|
+
const hr = container.querySelector('hr');
|
|
107
|
+
expect(hr).toHaveClass('border-gray-200');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('divider has dark mode class', () => {
|
|
111
|
+
const { container } = render(FormSection, { props: { divider: true } });
|
|
112
|
+
const hr = container.querySelector('hr');
|
|
113
|
+
expect(hr).toHaveClass('dark:border-gray-700');
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe('FormSection Content Area', () => {
|
|
118
|
+
test('has content div with space-y-4', () => {
|
|
119
|
+
const { container } = render(FormSection);
|
|
120
|
+
const contentDiv = container.querySelector('section > div.space-y-4');
|
|
121
|
+
expect(contentDiv).toBeInTheDocument();
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('FormSection Combinations', () => {
|
|
126
|
+
test('all props together', () => {
|
|
127
|
+
const { container } = render(FormSection, {
|
|
128
|
+
props: {
|
|
129
|
+
title: 'Address',
|
|
130
|
+
description: 'Your mailing address',
|
|
131
|
+
divider: true,
|
|
132
|
+
class: 'mt-6'
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
const section = container.querySelector('section');
|
|
136
|
+
expect(section).toHaveClass('mt-6');
|
|
137
|
+
expect(container.querySelector('hr')).toBeInTheDocument();
|
|
138
|
+
expect(screen.getByText('Address')).toBeInTheDocument();
|
|
139
|
+
expect(screen.getByText('Your mailing address')).toBeInTheDocument();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test('title only without description', () => {
|
|
143
|
+
const { container } = render(FormSection, { props: { title: 'Settings' } });
|
|
144
|
+
expect(container.querySelector('h3')).toBeInTheDocument();
|
|
145
|
+
expect(container.querySelector('p')).not.toBeInTheDocument();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('description only without title', () => {
|
|
149
|
+
const { container } = render(FormSection, { props: { description: 'Optional info' } });
|
|
150
|
+
expect(container.querySelector('h3')).not.toBeInTheDocument();
|
|
151
|
+
expect(container.querySelector('p')).toBeInTheDocument();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sidebar.spec.d.ts","sourceRoot":"","sources":["../../../src/lib/patterns/layout/Sidebar.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { render } from '@testing-library/svelte';
|
|
2
|
+
import { expect, describe, test } from 'vitest';
|
|
3
|
+
import Sidebar from './Sidebar.svelte';
|
|
4
|
+
|
|
5
|
+
describe('Sidebar Component', () => {
|
|
6
|
+
test('renders a wrapper div', () => {
|
|
7
|
+
const { container } = render(Sidebar);
|
|
8
|
+
expect(container.querySelector('div')).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('has flex layout', () => {
|
|
12
|
+
const { container } = render(Sidebar);
|
|
13
|
+
const wrapper = container.firstElementChild;
|
|
14
|
+
expect(wrapper).toHaveClass('flex');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('applies custom className', () => {
|
|
18
|
+
const { container } = render(Sidebar, { props: { class: 'custom-sidebar' } });
|
|
19
|
+
const wrapper = container.firstElementChild;
|
|
20
|
+
expect(wrapper).toHaveClass('custom-sidebar');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('Sidebar Position', () => {
|
|
25
|
+
test('default position is right', () => {
|
|
26
|
+
const { container } = render(Sidebar);
|
|
27
|
+
// When position is right, main comes first then aside
|
|
28
|
+
const children = container.firstElementChild.children;
|
|
29
|
+
expect(children[0].tagName).toBe('MAIN');
|
|
30
|
+
expect(children[1].tagName).toBe('ASIDE');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('position left puts sidebar first', () => {
|
|
34
|
+
const { container } = render(Sidebar, { props: { sidebarPosition: 'left' } });
|
|
35
|
+
const children = container.firstElementChild.children;
|
|
36
|
+
expect(children[0].tagName).toBe('ASIDE');
|
|
37
|
+
expect(children[1].tagName).toBe('MAIN');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('position right puts main first', () => {
|
|
41
|
+
const { container } = render(Sidebar, { props: { sidebarPosition: 'right' } });
|
|
42
|
+
const children = container.firstElementChild.children;
|
|
43
|
+
expect(children[0].tagName).toBe('MAIN');
|
|
44
|
+
expect(children[1].tagName).toBe('ASIDE');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('Sidebar Width', () => {
|
|
49
|
+
test('default width is medium', () => {
|
|
50
|
+
const { container } = render(Sidebar);
|
|
51
|
+
const aside = container.querySelector('aside');
|
|
52
|
+
expect(aside).toHaveClass('lg:w-80');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('narrow width applies lg:w-72', () => {
|
|
56
|
+
const { container } = render(Sidebar, { props: { sidebarWidth: 'narrow' } });
|
|
57
|
+
const aside = container.querySelector('aside');
|
|
58
|
+
expect(aside).toHaveClass('lg:w-72');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('medium width applies lg:w-80', () => {
|
|
62
|
+
const { container } = render(Sidebar, { props: { sidebarWidth: 'medium' } });
|
|
63
|
+
const aside = container.querySelector('aside');
|
|
64
|
+
expect(aside).toHaveClass('lg:w-80');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('wide width applies lg:w-96', () => {
|
|
68
|
+
const { container } = render(Sidebar, { props: { sidebarWidth: 'wide' } });
|
|
69
|
+
const aside = container.querySelector('aside');
|
|
70
|
+
expect(aside).toHaveClass('lg:w-96');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('Sidebar Main Width', () => {
|
|
75
|
+
test('narrow sidebar gives main lg:w-[calc(100%-18rem)]', () => {
|
|
76
|
+
const { container } = render(Sidebar, { props: { sidebarWidth: 'narrow' } });
|
|
77
|
+
const main = container.querySelector('main');
|
|
78
|
+
expect(main).toHaveClass('lg:w-[calc(100%-18rem)]');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('medium sidebar gives main lg:w-[calc(100%-20rem)]', () => {
|
|
82
|
+
const { container } = render(Sidebar, { props: { sidebarWidth: 'medium' } });
|
|
83
|
+
const main = container.querySelector('main');
|
|
84
|
+
expect(main).toHaveClass('lg:w-[calc(100%-20rem)]');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('wide sidebar gives main lg:w-[calc(100%-24rem)]', () => {
|
|
88
|
+
const { container } = render(Sidebar, { props: { sidebarWidth: 'wide' } });
|
|
89
|
+
const main = container.querySelector('main');
|
|
90
|
+
expect(main).toHaveClass('lg:w-[calc(100%-24rem)]');
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('Sidebar Responsive', () => {
|
|
95
|
+
test('has responsive flex direction', () => {
|
|
96
|
+
const { container } = render(Sidebar);
|
|
97
|
+
const wrapper = container.firstElementChild;
|
|
98
|
+
expect(wrapper).toHaveClass('flex-col');
|
|
99
|
+
expect(wrapper).toHaveClass('lg:flex-row');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('sidebar is full width on mobile', () => {
|
|
103
|
+
const { container } = render(Sidebar);
|
|
104
|
+
const aside = container.querySelector('aside');
|
|
105
|
+
expect(aside).toHaveClass('w-full');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('main is full width on mobile', () => {
|
|
109
|
+
const { container } = render(Sidebar);
|
|
110
|
+
const main = container.querySelector('main');
|
|
111
|
+
expect(main).toHaveClass('w-full');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('has gap between sidebar and main', () => {
|
|
115
|
+
const { container } = render(Sidebar);
|
|
116
|
+
const wrapper = container.firstElementChild;
|
|
117
|
+
expect(wrapper).toHaveClass('gap-6');
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
describe('Sidebar Combinations', () => {
|
|
122
|
+
test('all props together - left narrow', () => {
|
|
123
|
+
const { container } = render(Sidebar, {
|
|
124
|
+
props: {
|
|
125
|
+
sidebarWidth: 'narrow',
|
|
126
|
+
sidebarPosition: 'left',
|
|
127
|
+
class: 'custom-layout'
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const wrapper = container.firstElementChild;
|
|
131
|
+
expect(wrapper).toHaveClass('custom-layout');
|
|
132
|
+
|
|
133
|
+
const children = wrapper.children;
|
|
134
|
+
expect(children[0].tagName).toBe('ASIDE');
|
|
135
|
+
expect(children[0]).toHaveClass('lg:w-72');
|
|
136
|
+
|
|
137
|
+
expect(children[1].tagName).toBe('MAIN');
|
|
138
|
+
expect(children[1]).toHaveClass('lg:w-[calc(100%-18rem)]');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test('all props together - right wide', () => {
|
|
142
|
+
const { container } = render(Sidebar, {
|
|
143
|
+
props: {
|
|
144
|
+
sidebarWidth: 'wide',
|
|
145
|
+
sidebarPosition: 'right',
|
|
146
|
+
class: 'another-layout'
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
const wrapper = container.firstElementChild;
|
|
150
|
+
expect(wrapper).toHaveClass('another-layout');
|
|
151
|
+
|
|
152
|
+
const children = wrapper.children;
|
|
153
|
+
expect(children[0].tagName).toBe('MAIN');
|
|
154
|
+
expect(children[0]).toHaveClass('lg:w-[calc(100%-24rem)]');
|
|
155
|
+
|
|
156
|
+
expect(children[1].tagName).toBe('ASIDE');
|
|
157
|
+
expect(children[1]).toHaveClass('lg:w-96');
|
|
158
|
+
});
|
|
159
|
+
});
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
{#each links as { label, href, icon }}
|
|
47
47
|
<a
|
|
48
48
|
{href}
|
|
49
|
-
class={`flex-1 flex items-center justify-center py-3 px-2 no-underline bg-transparent border-none cursor-pointer min-w-0
|
|
49
|
+
class={`bottom-nav-item flex-1 flex items-center justify-center py-3 px-2 no-underline bg-transparent border-none cursor-pointer min-w-0
|
|
50
50
|
${typography.textMuted} transition-colors duration-150
|
|
51
51
|
hover:text-gray-900 hover:no-underline dark:hover:text-white
|
|
52
52
|
select-none touch-manipulation
|
|
53
|
-
${isActive(href, currentPath) ? 'text-blue-700 dark:text-blue-500' : ''}`}
|
|
53
|
+
${isActive(href, currentPath) ? 'active text-blue-700 dark:text-blue-500' : ''}`}
|
|
54
54
|
aria-label={label}
|
|
55
55
|
style="-webkit-tap-highlight-color: transparent; -webkit-touch-callout: none;"
|
|
56
56
|
>
|
|
57
|
-
<span class="relative flex items-center justify-center transition-transform duration-150 active:scale-[0.8]">
|
|
57
|
+
<span class="bottom-nav-icon relative flex items-center justify-center transition-transform duration-150 active:scale-[0.8]">
|
|
58
58
|
<Icon name={icon} size="24" />
|
|
59
59
|
{#if label === "Shows" && shows?.invitation?.length > 0}
|
|
60
|
-
<span class="absolute -top-1 -right-1 w-2 h-2 bg-red-500 rounded-full"></span>
|
|
60
|
+
<span class="notification-dot absolute -top-1 -right-1 w-2 h-2 bg-red-500 rounded-full"></span>
|
|
61
61
|
{/if}
|
|
62
62
|
</span>
|
|
63
63
|
</a>
|
|
@@ -56,69 +56,73 @@ describe('Header', () => {
|
|
|
56
56
|
});
|
|
57
57
|
describe('back button mode', () => {
|
|
58
58
|
it('shows back button when showBackButton is true', () => {
|
|
59
|
-
|
|
60
|
-
const backButton =
|
|
59
|
+
render(Header, { ...defaultProps, showBackButton: true });
|
|
60
|
+
const backButton = screen.getByText('Back');
|
|
61
61
|
expect(backButton).toBeTruthy();
|
|
62
62
|
});
|
|
63
63
|
it('does not show back button by default', () => {
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
expect(
|
|
64
|
+
render(Header, defaultProps);
|
|
65
|
+
const backButtons = screen.queryAllByText('Back');
|
|
66
|
+
expect(backButtons.length).toBe(0);
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
69
|
describe('avatar buttons', () => {
|
|
70
70
|
it('renders mobile avatar button', () => {
|
|
71
71
|
const { container } = render(Header, defaultProps);
|
|
72
|
-
|
|
72
|
+
// The mobile button has "block md:hidden" class
|
|
73
|
+
const mobileButton = container.querySelector('button.block.md\\:hidden');
|
|
73
74
|
expect(mobileButton).toBeTruthy();
|
|
74
75
|
});
|
|
75
76
|
it('renders desktop avatar button', () => {
|
|
76
77
|
const { container } = render(Header, defaultProps);
|
|
77
|
-
|
|
78
|
+
// The desktop button has "hidden md:block" class
|
|
79
|
+
const desktopButton = container.querySelector('button.hidden.md\\:block');
|
|
78
80
|
expect(desktopButton).toBeTruthy();
|
|
79
81
|
});
|
|
80
82
|
});
|
|
81
83
|
describe('desktop dropdown', () => {
|
|
82
84
|
it('shows dropdown when desktop avatar is clicked', async () => {
|
|
83
85
|
const { container } = render(Header, defaultProps);
|
|
84
|
-
const desktopButton = container.querySelector('.
|
|
86
|
+
const desktopButton = container.querySelector('button.hidden.md\\:block');
|
|
85
87
|
await fireEvent.click(desktopButton);
|
|
86
|
-
|
|
88
|
+
// Look for the dropdown by its class - it's an absolute positioned div with specific classes
|
|
89
|
+
const dropdown = container.querySelector('div.absolute.top-\\[calc\\(100\\%\\+0\\.5rem\\)\\]');
|
|
87
90
|
expect(dropdown).toBeTruthy();
|
|
88
91
|
});
|
|
89
92
|
it('displays user name and email in dropdown', async () => {
|
|
90
93
|
const { container } = render(Header, defaultProps);
|
|
91
|
-
const desktopButton = container.querySelector('.
|
|
94
|
+
const desktopButton = container.querySelector('button.hidden.md\\:block');
|
|
92
95
|
await fireEvent.click(desktopButton);
|
|
93
96
|
expect(screen.getByText('Test Performer')).toBeTruthy();
|
|
94
97
|
expect(screen.getByText('test@example.com')).toBeTruthy();
|
|
95
98
|
});
|
|
96
99
|
it('displays dropdown links', async () => {
|
|
97
100
|
const { container } = render(Header, defaultProps);
|
|
98
|
-
const desktopButton = container.querySelector('.
|
|
101
|
+
const desktopButton = container.querySelector('button.hidden.md\\:block');
|
|
99
102
|
await fireEvent.click(desktopButton);
|
|
100
103
|
expect(screen.getByText('Account Settings')).toBeTruthy();
|
|
101
104
|
expect(screen.getByText('Payment Settings')).toBeTruthy();
|
|
102
105
|
});
|
|
103
106
|
it('displays sign out button', async () => {
|
|
104
107
|
const { container } = render(Header, defaultProps);
|
|
105
|
-
const desktopButton = container.querySelector('.
|
|
108
|
+
const desktopButton = container.querySelector('button.hidden.md\\:block');
|
|
106
109
|
await fireEvent.click(desktopButton);
|
|
107
110
|
expect(screen.getByText('Sign out')).toBeTruthy();
|
|
108
111
|
});
|
|
109
112
|
it('closes dropdown when backdrop is clicked', async () => {
|
|
110
113
|
const { container } = render(Header, defaultProps);
|
|
111
|
-
const desktopButton = container.querySelector('.
|
|
114
|
+
const desktopButton = container.querySelector('button.hidden.md\\:block');
|
|
112
115
|
await fireEvent.click(desktopButton);
|
|
113
|
-
|
|
116
|
+
// The backdrop is the fixed inset-0 div with z-30
|
|
117
|
+
const backdrop = container.querySelector('div.fixed.inset-0.z-30');
|
|
114
118
|
await fireEvent.click(backdrop);
|
|
115
|
-
const dropdown = container.querySelector('.
|
|
119
|
+
const dropdown = container.querySelector('div.absolute.top-\\[calc\\(100\\%\\+0\\.5rem\\)\\]');
|
|
116
120
|
expect(dropdown).toBeFalsy();
|
|
117
121
|
});
|
|
118
122
|
it('calls signoutHandler when sign out is clicked', async () => {
|
|
119
123
|
const signoutHandler = vi.fn();
|
|
120
124
|
const { container } = render(Header, { ...defaultProps, signoutHandler });
|
|
121
|
-
const desktopButton = container.querySelector('.
|
|
125
|
+
const desktopButton = container.querySelector('button.hidden.md\\:block');
|
|
122
126
|
await fireEvent.click(desktopButton);
|
|
123
127
|
const signOutButton = screen.getByText('Sign out');
|
|
124
128
|
await fireEvent.click(signOutButton);
|
|
@@ -126,34 +130,39 @@ describe('Header', () => {
|
|
|
126
130
|
});
|
|
127
131
|
it('toggles dropdown on repeated clicks', async () => {
|
|
128
132
|
const { container } = render(Header, defaultProps);
|
|
129
|
-
const desktopButton = container.querySelector('.
|
|
133
|
+
const desktopButton = container.querySelector('button.hidden.md\\:block');
|
|
130
134
|
await fireEvent.click(desktopButton);
|
|
131
|
-
expect(container.querySelector('.
|
|
135
|
+
expect(container.querySelector('div.absolute.top-\\[calc\\(100\\%\\+0\\.5rem\\)\\]')).toBeTruthy();
|
|
132
136
|
await fireEvent.click(desktopButton);
|
|
133
|
-
expect(container.querySelector('.
|
|
137
|
+
expect(container.querySelector('div.absolute.top-\\[calc\\(100\\%\\+0\\.5rem\\)\\]')).toBeFalsy();
|
|
134
138
|
});
|
|
135
139
|
});
|
|
136
140
|
describe('mobile sheet', () => {
|
|
137
141
|
it('triggers mobile sheet state when mobile avatar is clicked', async () => {
|
|
138
142
|
const { container } = render(Header, defaultProps);
|
|
139
|
-
const mobileButton = container.querySelector('.
|
|
140
|
-
// Click should trigger the sheet opening (internal state)
|
|
141
|
-
await fireEvent.click(mobileButton);
|
|
143
|
+
const mobileButton = container.querySelector('button.block.md\\:hidden');
|
|
142
144
|
// The mobile button should exist and be clickable
|
|
143
145
|
expect(mobileButton).toBeTruthy();
|
|
146
|
+
// Click should trigger the sheet opening (internal state)
|
|
147
|
+
await fireEvent.click(mobileButton);
|
|
148
|
+
// The mobile sheet uses portal action to render to document.body,
|
|
149
|
+
// so we need to check in document.body instead of container
|
|
150
|
+
const mobileSheet = document.body.querySelector('div.fixed.inset-0.bg-black\\/50');
|
|
151
|
+
expect(mobileSheet).toBeTruthy();
|
|
144
152
|
});
|
|
145
153
|
});
|
|
146
154
|
describe('navigation active state', () => {
|
|
147
155
|
it('marks current path as active', () => {
|
|
148
156
|
const { container } = render(Header, defaultProps);
|
|
149
157
|
const showsLink = container.querySelector('a[href="/shows"]');
|
|
150
|
-
|
|
158
|
+
// The active link should have 'text-blue-700' class (or dark mode 'dark:text-blue-500')
|
|
159
|
+
expect(showsLink.classList.contains('text-blue-700')).toBe(true);
|
|
151
160
|
});
|
|
152
161
|
});
|
|
153
162
|
describe('default values', () => {
|
|
154
163
|
it('shows "Performer" when name is empty', async () => {
|
|
155
164
|
const { container } = render(Header, { ...defaultProps, name: '' });
|
|
156
|
-
const desktopButton = container.querySelector('.
|
|
165
|
+
const desktopButton = container.querySelector('button.hidden.md\\:block');
|
|
157
166
|
await fireEvent.click(desktopButton);
|
|
158
167
|
expect(screen.getByText('Performer')).toBeTruthy();
|
|
159
168
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageHeader.spec.d.ts","sourceRoot":"","sources":["../../../src/lib/patterns/page/PageHeader.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/svelte';
|
|
2
|
+
import { expect, describe, test } from 'vitest';
|
|
3
|
+
import PageHeader from './PageHeader.svelte';
|
|
4
|
+
|
|
5
|
+
describe('PageHeader Component', () => {
|
|
6
|
+
test('renders a header element', () => {
|
|
7
|
+
const { container } = render(PageHeader);
|
|
8
|
+
expect(container.querySelector('header')).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('has space-y-4 class', () => {
|
|
12
|
+
const { container } = render(PageHeader);
|
|
13
|
+
const header = container.querySelector('header');
|
|
14
|
+
expect(header).toHaveClass('space-y-4');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('applies custom className', () => {
|
|
18
|
+
const { container } = render(PageHeader, { props: { class: 'custom-header' } });
|
|
19
|
+
const header = container.querySelector('header');
|
|
20
|
+
expect(header).toHaveClass('custom-header');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('PageHeader Title', () => {
|
|
25
|
+
test('no title renders no h1', () => {
|
|
26
|
+
const { container } = render(PageHeader);
|
|
27
|
+
expect(container.querySelector('h1')).not.toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('title prop renders h1', () => {
|
|
31
|
+
render(PageHeader, { props: { title: 'Dashboard' } });
|
|
32
|
+
expect(screen.getByText('Dashboard')).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('title is in h1 element', () => {
|
|
36
|
+
const { container } = render(PageHeader, { props: { title: 'Settings' } });
|
|
37
|
+
const h1 = container.querySelector('h1');
|
|
38
|
+
expect(h1).toBeInTheDocument();
|
|
39
|
+
expect(h1).toHaveTextContent('Settings');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('PageHeader Subtitle', () => {
|
|
44
|
+
test('no subtitle renders no p', () => {
|
|
45
|
+
const { container } = render(PageHeader);
|
|
46
|
+
expect(container.querySelector('p')).not.toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('subtitle prop renders p', () => {
|
|
50
|
+
render(PageHeader, { props: { subtitle: 'Manage your account' } });
|
|
51
|
+
expect(screen.getByText('Manage your account')).toBeInTheDocument();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('subtitle is in p element', () => {
|
|
55
|
+
const { container } = render(PageHeader, { props: { subtitle: 'Welcome back' } });
|
|
56
|
+
const p = container.querySelector('p');
|
|
57
|
+
expect(p).toBeInTheDocument();
|
|
58
|
+
expect(p).toHaveTextContent('Welcome back');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('subtitle p has mt-1 margin', () => {
|
|
62
|
+
const { container } = render(PageHeader, { props: { subtitle: 'Test' } });
|
|
63
|
+
const p = container.querySelector('p');
|
|
64
|
+
expect(p).toHaveClass('mt-1');
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe('PageHeader Breadcrumb', () => {
|
|
69
|
+
test('no breadcrumb by default', () => {
|
|
70
|
+
const { container } = render(PageHeader);
|
|
71
|
+
expect(container.querySelector('nav')).not.toBeInTheDocument();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('empty breadcrumb array renders no nav', () => {
|
|
75
|
+
const { container } = render(PageHeader, { props: { breadcrumb: [] } });
|
|
76
|
+
expect(container.querySelector('nav')).not.toBeInTheDocument();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('breadcrumb with items renders nav', () => {
|
|
80
|
+
const { container } = render(PageHeader, {
|
|
81
|
+
props: {
|
|
82
|
+
breadcrumb: [
|
|
83
|
+
{ name: 'Home', href: '/' },
|
|
84
|
+
{ name: 'Settings', href: '/settings' }
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
expect(container.querySelector('nav')).toBeInTheDocument();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('breadcrumb links are rendered', () => {
|
|
92
|
+
render(PageHeader, {
|
|
93
|
+
props: {
|
|
94
|
+
breadcrumb: [{ name: 'Home', href: '/' }]
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
expect(screen.getByText('Home')).toBeInTheDocument();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('PageHeader Layout', () => {
|
|
102
|
+
test('has flex container for title and actions', () => {
|
|
103
|
+
const { container } = render(PageHeader, { props: { title: 'Test' } });
|
|
104
|
+
const flexDiv = container.querySelector('header > div.flex');
|
|
105
|
+
expect(flexDiv).toBeInTheDocument();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('flex container has responsive classes', () => {
|
|
109
|
+
const { container } = render(PageHeader, { props: { title: 'Test' } });
|
|
110
|
+
const flexDiv = container.querySelector('header > div.flex');
|
|
111
|
+
expect(flexDiv).toHaveClass('flex-col');
|
|
112
|
+
expect(flexDiv).toHaveClass('sm:flex-row');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test('flex container has gap-4', () => {
|
|
116
|
+
const { container } = render(PageHeader, { props: { title: 'Test' } });
|
|
117
|
+
const flexDiv = container.querySelector('header > div.flex');
|
|
118
|
+
expect(flexDiv).toHaveClass('gap-4');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('flex container has sm:items-center', () => {
|
|
122
|
+
const { container } = render(PageHeader, { props: { title: 'Test' } });
|
|
123
|
+
const flexDiv = container.querySelector('header > div.flex');
|
|
124
|
+
expect(flexDiv).toHaveClass('sm:items-center');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('flex container has sm:justify-between', () => {
|
|
128
|
+
const { container } = render(PageHeader, { props: { title: 'Test' } });
|
|
129
|
+
const flexDiv = container.querySelector('header > div.flex');
|
|
130
|
+
expect(flexDiv).toHaveClass('sm:justify-between');
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe('PageHeader Combinations', () => {
|
|
135
|
+
test('title and subtitle together', () => {
|
|
136
|
+
render(PageHeader, { props: { title: 'Users', subtitle: 'Manage all users' } });
|
|
137
|
+
expect(screen.getByText('Users')).toBeInTheDocument();
|
|
138
|
+
expect(screen.getByText('Manage all users')).toBeInTheDocument();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test('breadcrumb with title', () => {
|
|
142
|
+
const { container } = render(PageHeader, {
|
|
143
|
+
props: {
|
|
144
|
+
title: 'Profile',
|
|
145
|
+
breadcrumb: [{ name: 'Settings', href: '/settings' }]
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
expect(container.querySelector('nav')).toBeInTheDocument();
|
|
149
|
+
expect(screen.getByText('Profile')).toBeInTheDocument();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('all props together', () => {
|
|
153
|
+
const { container } = render(PageHeader, {
|
|
154
|
+
props: {
|
|
155
|
+
title: 'Account',
|
|
156
|
+
subtitle: 'Update your details',
|
|
157
|
+
breadcrumb: [{ name: 'Home', href: '/' }],
|
|
158
|
+
class: 'mb-8'
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
const header = container.querySelector('header');
|
|
162
|
+
expect(header).toHaveClass('mb-8');
|
|
163
|
+
expect(container.querySelector('nav')).toBeInTheDocument();
|
|
164
|
+
expect(screen.getByText('Account')).toBeInTheDocument();
|
|
165
|
+
expect(screen.getByText('Update your details')).toBeInTheDocument();
|
|
166
|
+
});
|
|
167
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageLayout.spec.d.ts","sourceRoot":"","sources":["../../../src/lib/patterns/page/PageLayout.spec.js"],"names":[],"mappings":""}
|