2026-02-02 20:34:35 +00:00
|
|
|
// Learn more: https://github.com/testing-library/jest-dom
|
|
|
|
|
import '@testing-library/jest-dom';
|
|
|
|
|
|
|
|
|
|
// Mock Next.js router
|
|
|
|
|
jest.mock('next/navigation', () => ({
|
|
|
|
|
useRouter: () => ({
|
|
|
|
|
push: jest.fn(),
|
|
|
|
|
replace: jest.fn(),
|
|
|
|
|
prefetch: jest.fn(),
|
|
|
|
|
}),
|
|
|
|
|
usePathname: () => '/',
|
|
|
|
|
useSearchParams: () => new URLSearchParams(),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// Mock window.matchMedia
|
|
|
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
|
|
|
writable: true,
|
|
|
|
|
value: jest.fn().mockImplementation((query) => ({
|
|
|
|
|
matches: false,
|
|
|
|
|
media: query,
|
|
|
|
|
onchange: null,
|
|
|
|
|
addListener: jest.fn(),
|
|
|
|
|
removeListener: jest.fn(),
|
|
|
|
|
addEventListener: jest.fn(),
|
|
|
|
|
removeEventListener: jest.fn(),
|
|
|
|
|
dispatchEvent: jest.fn(),
|
|
|
|
|
})),
|
|
|
|
|
});
|
|
|
|
|
|
2026-08-01 21:06:14 +01:00
|
|
|
// 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();
|
|
|
|
|
|
2026-02-02 20:34:35 +00:00
|
|
|
// Mock localStorage
|
|
|
|
|
const localStorageMock = {
|
|
|
|
|
getItem: jest.fn(),
|
|
|
|
|
setItem: jest.fn(),
|
|
|
|
|
removeItem: jest.fn(),
|
|
|
|
|
clear: jest.fn(),
|
|
|
|
|
};
|
|
|
|
|
global.localStorage = localStorageMock;
|