PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m13s
PR Checks / Backend Smoke (pull_request) Successful in 10s
PR Checks / Build Backend (no push) (pull_request) Successful in 18s
PR Checks / Build Frontend (no push) (pull_request) Successful in 1m19s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 11s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 16s
GIAS NurseryProvision is text ("Has Nursery Classes", "No Nursery
Classes", "Not applicable"), but the header and the place table tested it
for truthiness. Every school with a value got a Nursery chip or a "Yes",
including secondaries aged 11-18. hasNurseryClasses() matches the one
value that means a nursery, and the type now says the field is a string.
The single-sex chip appended 's to the plural GIAS gender, giving
"Girls's school". singleSexLabel() gives "Girls' school" / "Boys' school".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
2.5 KiB
TypeScript
67 lines
2.5 KiB
TypeScript
/**
|
||
* The facts row under the school name.
|
||
*
|
||
* nursery_provision is GIAS text, not a boolean: "Has Nursery Classes",
|
||
* "No Nursery Classes" or "Not applicable". Tested for truthiness, every one
|
||
* of those read as a nursery, so secondaries aged 11–18 showed "Nursery".
|
||
*/
|
||
|
||
import { screen } from '@testing-library/react';
|
||
import { primaryFixture, secondaryFixture } from '../support/schoolFixtures';
|
||
import { renderSchoolDetail, renderSecondarySchoolDetail } from '../support/renderSchoolDetail';
|
||
|
||
jest.mock('@/lib/analytics', () => ({
|
||
track: jest.fn(),
|
||
getNavigationSource: () => 'direct',
|
||
}));
|
||
jest.mock('@/components/PerformanceChart', () => ({
|
||
PerformanceChart: () => <div data-testid="performance-chart" />,
|
||
}));
|
||
jest.mock('@/components/SatsChart', () => ({
|
||
__esModule: true,
|
||
default: () => <div data-testid="sats-chart" />,
|
||
}));
|
||
jest.mock('@/components/AdmissionsTrendChart', () => ({
|
||
__esModule: true,
|
||
default: () => <div data-testid="admissions-trend-chart" />,
|
||
}));
|
||
jest.mock('@/components/SchoolHeroMap', () => ({
|
||
SchoolHeroMap: () => <div data-testid="hero-map" />,
|
||
__esModule: true,
|
||
}));
|
||
|
||
function withSchool<T extends { schoolInfo: object }>(fixture: T, info: object): T {
|
||
return { ...fixture, schoolInfo: { ...fixture.schoolInfo, ...info } };
|
||
}
|
||
|
||
describe('school header nursery chip', () => {
|
||
it('shows Nursery when GIAS says the school has nursery classes', () => {
|
||
renderSchoolDetail(withSchool(primaryFixture, { nursery_provision: 'Has Nursery Classes' }));
|
||
expect(screen.getByText('Nursery', { selector: 'span' })).toBeInTheDocument();
|
||
});
|
||
|
||
it.each(['No Nursery Classes', 'Not applicable', null])(
|
||
'hides Nursery when GIAS says %p',
|
||
(value) => {
|
||
renderSecondarySchoolDetail(withSchool(secondaryFixture, { nursery_provision: value }));
|
||
expect(screen.queryByText('Nursery', { selector: 'span' })).not.toBeInTheDocument();
|
||
},
|
||
);
|
||
});
|
||
|
||
describe('school header single-sex chip', () => {
|
||
it.each([['Girls', "Girls' school"], ['Boys', "Boys' school"]])(
|
||
'labels a %s school with a plural possessive',
|
||
(gender, label) => {
|
||
renderSecondarySchoolDetail(withSchool(secondaryFixture, { gender }));
|
||
expect(screen.getByText(label)).toBeInTheDocument();
|
||
expect(screen.queryByText(/'s school/)).not.toBeInTheDocument();
|
||
},
|
||
);
|
||
|
||
it('says nothing for a mixed school', () => {
|
||
renderSecondarySchoolDetail(withSchool(secondaryFixture, { gender: 'Mixed' }));
|
||
expect(screen.queryByText(/school$/, { selector: 'span' })).not.toBeInTheDocument();
|
||
});
|
||
});
|