Files
AndreaSlopFotografie/web/src/components/HomeSection/HomeSection.test.tsx
T
SluijsensandClaude Opus 5.5 52c1864a38 Adds the Instagram section to the homepage
Shows the handle as a link to the profile and six square photos from edge
to edge (2, 3 or 6 per row), each linking to the profile in a new tab.
The photos are ones the page already loads, so the section adds no
downloads; the API will later fill it with the real feed. Without a valid
https link to Instagram the section is left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 00:26:41 +02:00

52 lines
1.8 KiB
TypeScript

import { screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import HomeSection from './HomeSection';
describe('HomeSection', () => {
it('is a region named by its heading', async () => {
const { container } = await renderWithProviders(
<HomeSection labelledBy="about-title" data-testid="about">
<h2 id="about-title">Over mij</h2>
</HomeSection>,
);
expect(screen.getByRole('region', { name: 'Over mij' })).toBe(
screen.getByTestId('about'),
);
expect(await axeResults(container)).toHaveNoViolations();
});
it('passes the anchor id through for every tone, width and spacing', async () => {
await renderWithProviders(
<HomeSection
labelledBy="contact-title"
id="contact"
tone="alt"
width="narrow"
spacing="tight"
>
<h2 id="contact-title">Contact</h2>
</HomeSection>,
);
expect(screen.getByRole('region', { name: 'Contact' })).toHaveAttribute(
'id',
'contact',
);
});
it('leaves out the content column at full width', async () => {
await renderWithProviders(
<HomeSection labelledBy="insta-title" width="full">
<h2 id="insta-title" data-testid="child">
Instagram
</h2>
</HomeSection>,
);
// The heading is a direct child of the section, not of a Container
expect(screen.getByTestId('child').parentElement).toBe(
screen.getByRole('region', { name: 'Instagram' }),
);
});
});