import React from 'react'; import { render, screen } from '@testing-library/react'; import { describe, it, expect } from 'vitest'; import { Header, Main, Footer, Aside, Section, Article, Fieldset, } from './landmarks'; /** * Landmarks wrap semantic HTML5 elements (header, main, footer, aside, * section, article, fieldset) so consumers get accessible structure without * hand-authoring the tags. Tests focus on: (1) the correct element renders, * (2) children pass through, (3) props forward to the DOM, (4) ARIA roles * are exposed correctly by the semantic element. */ describe('Layout landmarks', () => { describe('Header', () => { it('renders a
with banner role by default', () => { render(
Site header
); const banner = screen.getByRole('banner'); expect(banner.tagName).toBe('HEADER'); expect(banner).toHaveTextContent('Site header'); }); it('renders optional headerBackground before content', () => { render(
bg}> Hello
); const bg = screen.getByTestId('bg'); expect(bg).toBeInTheDocument(); // background must precede the inner section in source order expect(bg.nextElementSibling?.tagName).toBe('SECTION'); }); }); describe('Main', () => { it('renders a
with main role', () => { render(
Content
); const main = screen.getByRole('main'); expect(main.tagName).toBe('MAIN'); expect(main).toHaveTextContent('Content'); }); }); describe('Footer', () => { it('renders a