test: add jsdom globals and school detail fixtures

jsdom provides neither IntersectionObserver nor scrollTo; both detail views
use them. Adds four fixtures (primary, secondary, all-through, special)
covering the branches the characterization tests will pin.

SchoolResult carries 57 required nullable fields, so fixtures are built from
an all-null base row and override only what they exercise.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Tudor
2026-08-01 21:06:14 +01:00
co-authored by Claude Opus 5
parent 7199c3a90b
commit bcf3498086
2 changed files with 349 additions and 0 deletions
+17
View File
@@ -27,6 +27,23 @@ Object.defineProperty(window, 'matchMedia', {
})),
});
// jsdom implements neither of these; the school detail views use both
// (IntersectionObserver for the scroll-spy and the hero-CTA tracker,
// scrollTo for the "back to top" control).
global.IntersectionObserver = class {
constructor(callback) {
this.callback = callback;
}
observe() {}
unobserve() {}
disconnect() {}
takeRecords() {
return [];
}
};
window.scrollTo = jest.fn();
// Mock localStorage
const localStorageMock = {
getItem: jest.fn(),