diff --git a/src/shared/ui/FooterLink/FooterLink.stories.svelte b/src/shared/ui/FooterLink/FooterLink.stories.svelte new file mode 100644 index 0000000..7462b26 --- /dev/null +++ b/src/shared/ui/FooterLink/FooterLink.stories.svelte @@ -0,0 +1,53 @@ + + + + {#snippet template(args: ComponentProps)} + + {/snippet} + + + + {#snippet template()} +
+ + + +
+ {/snippet} +
diff --git a/src/shared/ui/FooterLink/FooterLink.svelte b/src/shared/ui/FooterLink/FooterLink.svelte new file mode 100644 index 0000000..3b6a8e9 --- /dev/null +++ b/src/shared/ui/FooterLink/FooterLink.svelte @@ -0,0 +1,48 @@ + + + + + {text} + + diff --git a/src/shared/ui/FooterLink/FooterLink.svelte.test.ts b/src/shared/ui/FooterLink/FooterLink.svelte.test.ts new file mode 100644 index 0000000..66435a7 --- /dev/null +++ b/src/shared/ui/FooterLink/FooterLink.svelte.test.ts @@ -0,0 +1,58 @@ +import { + render, + screen, +} from '@testing-library/svelte'; +import FooterLink from './FooterLink.svelte'; + +describe('FooterLink', () => { + const defaultProps = { + text: 'Google Fonts', + href: 'https://fonts.google.com', + }; + + describe('Rendering', () => { + it('renders text content', () => { + render(FooterLink, { props: defaultProps }); + expect(screen.getByText('Google Fonts')).toBeInTheDocument(); + }); + + it('renders as an anchor element with correct href', () => { + render(FooterLink, { props: defaultProps }); + const link = screen.getByRole('link'); + expect(link).toBeInTheDocument(); + expect(link).toHaveAttribute('href', 'https://fonts.google.com'); + }); + + it('renders the arrow icon', () => { + const { container } = render(FooterLink, { props: defaultProps }); + const icon = container.querySelector('svg'); + expect(icon).toBeInTheDocument(); + expect(icon).toHaveClass('lucide-arrow-up-right'); + }); + }); + + describe('Attributes', () => { + it('applies custom CSS classes', () => { + render(FooterLink, { + props: { + ...defaultProps, + class: 'custom-class', + }, + }); + expect(screen.getByRole('link')).toHaveClass('custom-class'); + }); + + it('spreads additional anchor attributes', () => { + render(FooterLink, { + props: { + ...defaultProps, + target: '_blank', + rel: 'noopener', + }, + }); + const link = screen.getByRole('link'); + expect(link).toHaveAttribute('target', '_blank'); + expect(link).toHaveAttribute('rel', 'noopener'); + }); + }); +}); diff --git a/src/shared/ui/index.ts b/src/shared/ui/index.ts index 7be032d..15688ee 100644 --- a/src/shared/ui/index.ts +++ b/src/shared/ui/index.ts @@ -52,6 +52,12 @@ export { */ default as FilterGroup, } from './FilterGroup/FilterGroup.svelte'; +export { + /** + * Standard footer link with arrow icon and hover effects + */ + default as FooterLink, +} from './FooterLink/FooterLink.svelte'; export { /** * Small text for secondary meta-information