- 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>
35 lines
871 B
TypeScript
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();
|
|
});
|
|
});
|