66 lines
2.5 KiB
TypeScript
66 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();
|
|||
|
|
});
|
|||
|
|
});
|