Files
AndreaSlopFotografie/web/src/components/MediaText/MediaText.test.tsx
T
SluijsensandClaude Opus 5.5 01e849c6b0 Extracts shared section blocks for use beyond the homepage
HomeSection becomes PageSection, since every page needs the same section
frame, and gains a flushTop spacing for a block right below a page head.
The framed photo next to text from the homepage About block becomes
MediaText, and the accent label that four components wrote out by hand
becomes Eyebrow, which can also render as a heading. The homepage renders
exactly as before: a layout comparison of every element against master
at three widths shows no differences.

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

47 lines
1.6 KiB
TypeScript

import { screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import type { ContentImage } from '@/content/types';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import MediaText from './MediaText';
const image: ContentImage = {
src: '/andrea.jpg',
alt: 'Andrea met haar camera',
width: 1200,
height: 800,
};
describe('MediaText', () => {
it('shows the photo and the text column', async () => {
const { container } = await renderWithProviders(
<MediaText image={image} aspectRatio="4 / 3" data-testid="block">
<h2>Hoi! Ik ben Andrea</h2>
<p>Lifestyle fotograaf uit Huizen.</p>
</MediaText>,
);
expect(screen.getByRole('img')).toHaveAccessibleName(image.alt);
expect(
screen.getByRole('heading', { name: 'Hoi! Ik ben Andrea' }),
).toBeInTheDocument();
expect(
screen.getByText('Lifestyle fotograaf uit Huizen.'),
).toBeInTheDocument();
expect(await axeResults(container)).toHaveNoViolations();
});
it('puts the photo before the text, also when stacked', async () => {
await renderWithProviders(
<MediaText image={image} aspectRatio="4 / 3">
<h2>Hoi! Ik ben Andrea</h2>
</MediaText>,
);
const photo = screen.getByRole('img');
const heading = screen.getByRole('heading');
expect(
photo.compareDocumentPosition(heading) &
Node.DOCUMENT_POSITION_FOLLOWING,
).toBeTruthy();
});
});