import { screen } from '@testing-library/react'; import { describe, expect, it } from 'vitest'; import { axeResults } from '@/test/axe'; import { renderWithProviders } from '@/test/renderWithProviders'; import PageSection from './PageSection'; describe('PageSection', () => { it('is a region named by its heading', async () => { const { container } = await renderWithProviders(

Over mij

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

Contact

, ); expect(screen.getByRole('region', { name: 'Contact' })).toHaveAttribute( 'id', 'contact', ); }); it('has no space above when it sits flush below a page head', async () => { await renderWithProviders( <>

Hoi!

Verder

, ); const regular = getComputedStyle(screen.getByTestId('flush')); const flush = getComputedStyle(screen.getByTestId('flush-top')); expect(flush.paddingTop).toBe('0px'); expect(flush.paddingBottom).toBe(regular.paddingBottom); expect(regular.paddingTop).not.toBe('0px'); }); it('is no landmark without a heading to name it', async () => { const { container } = await renderWithProviders(

Foto's

, ); expect(screen.getByTestId('photos').tagName).toBe('SECTION'); expect(screen.queryByRole('region')).not.toBeInTheDocument(); expect(await axeResults(container)).toHaveNoViolations(); }); it('leaves out the content column at full width', async () => { await renderWithProviders(

Instagram

, ); // The heading is a direct child of the section, not of a Container expect(screen.getByTestId('child').parentElement).toBe( screen.getByRole('region', { name: 'Instagram' }), ); }); });