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(

Hoi! Ik ben Andrea

Lifestyle fotograaf uit Huizen.

, ); 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(

Hoi! Ik ben Andrea

, ); const photo = screen.getByRole('img'); const heading = screen.getByRole('heading'); expect( photo.compareDocumentPosition(heading) & Node.DOCUMENT_POSITION_FOLLOWING, ).toBeTruthy(); }); });