2026-10-02 22:50:44 +01:00
|
|
|
/**
|
|
|
|
|
* 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(<SchoolRow school={{ ...base, religious_denomination }} />);
|
|
|
|
|
expect(screen.queryByText('None')).not.toBeInTheDocument();
|
|
|
|
|
expect(screen.queryByText('Does not apply')).not.toBeInTheDocument();
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
it('prints a religious character the school has', () => {
|
|
|
|
|
render(<SchoolRow school={{ ...base, religious_denomination: 'Church of England' }} />);
|
|
|
|
|
expect(screen.getByText('Church of England')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|
2026-10-02 22:59:45 +01:00
|
|
|
|
|
|
|
|
describe('SchoolRow shares the school page flags', () => {
|
|
|
|
|
it("prints the type in the search filter's terms", () => {
|
|
|
|
|
render(<SchoolRow school={{ ...base, type_group: 'state' }} />);
|
|
|
|
|
expect(screen.getByText('State school')).toBeInTheDocument();
|
|
|
|
|
expect(screen.queryByText('Free schools')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('flags a nursery class', () => {
|
|
|
|
|
render(<SchoolRow school={{ ...base, nursery_provision: 'Has Nursery Classes' }} />);
|
|
|
|
|
expect(screen.getByText('Nursery class')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("flags a boys' school", () => {
|
|
|
|
|
render(<SchoolRow school={{ ...base, gender: 'Boys' }} />);
|
|
|
|
|
expect(screen.getByText("Boys' school")).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|