/** * SchoolRow (primary search results): line 2 prints the religious character * only when the school has one. The register's "None" was printed as a chip. */ import '@testing-library/jest-dom'; import { render, screen } from '@testing-library/react'; import { SchoolRow } from '@/components/SchoolRow'; import type { School } from '@/lib/types'; const base = { urn: 100001, school_name: 'Alpha Primary School', local_authority: 'Testshire', school_type: 'Free schools', phase: 'Primary', gender: 'Mixed', age_range: '4-11', rwm_expected_pct: 70, } as unknown as School; describe('SchoolRow religious character', () => { it.each(['None', 'Does not apply', ''])( 'prints nothing when the register says %p', (religious_denomination) => { render(); expect(screen.queryByText('None')).not.toBeInTheDocument(); expect(screen.queryByText('Does not apply')).not.toBeInTheDocument(); }, ); it('prints a religious character the school has', () => { render(); expect(screen.getByText('Church of England')).toBeInTheDocument(); }); }); describe('SchoolRow shares the school page flags', () => { it("prints the type in the search filter's terms", () => { render(); expect(screen.getByText('State school')).toBeInTheDocument(); expect(screen.queryByText('Free schools')).not.toBeInTheDocument(); }); it('flags a nursery class', () => { render(); expect(screen.getByText('Nursery class')).toBeInTheDocument(); }); it("flags a boys' school", () => { render(); expect(screen.getByText("Boys' school")).toBeInTheDocument(); }); });