Files
ragusaitweb/src/components/ui/__tests__/SkipLink.test.tsx
google-labs-jules[bot] 7018459185 feat: add accessible Skip to Content link
- Add SkipLink component with off-screen styling
- Add translation keys for skip link text
- Integrate SkipLink in App.tsx and wrap content in #main-content
- Add unit tests for SkipLink

Co-authored-by: ragusa-it <196988693+ragusa-it@users.noreply.github.com>
2026-02-07 01:53:13 +00:00

35 lines
871 B
TypeScript

// @vitest-environment jsdom
import { render, screen, cleanup } from '@testing-library/react';
import { describe, it, expect, afterEach, vi } from 'vitest';
import { SkipLink } from '../SkipLink';
// Mock i18n
vi.mock('../../../i18n', () => ({
useTranslation: () => ({
t: {
nav: {
skipToContent: 'Skip to content',
},
},
}),
}));
describe('SkipLink', () => {
afterEach(() => {
cleanup();
});
it('renders a link with correct href and text', () => {
render(<SkipLink />);
const link = screen.getByRole('link', { name: /skip to content/i });
expect(link).toBeTruthy();
expect(link.getAttribute('href')).toBe('#main-content');
});
it('has class attribute for styling', () => {
render(<SkipLink />);
const link = screen.getByRole('link');
expect(link.getAttribute('class')).toBeTruthy();
});
});