66 lines
1.5 KiB
JavaScript
66 lines
1.5 KiB
JavaScript
import '@testing-library/jest-dom';
|
|
|
|
// Mock Next.js router
|
|
jest.mock('next/navigation', () => ({
|
|
useRouter() {
|
|
return {
|
|
push: jest.fn(),
|
|
replace: jest.fn(),
|
|
prefetch: jest.fn(),
|
|
back: jest.fn(),
|
|
forward: jest.fn(),
|
|
refresh: jest.fn(),
|
|
};
|
|
},
|
|
useSearchParams() {
|
|
return new URLSearchParams();
|
|
},
|
|
usePathname() {
|
|
return '/';
|
|
},
|
|
}));
|
|
|
|
// Mock Next.js image
|
|
jest.mock('next/image', () => ({
|
|
__esModule: true,
|
|
default: (props) => {
|
|
// eslint-disable-next-line @next/next/no-img-element
|
|
return <img {...props} />;
|
|
},
|
|
}));
|
|
|
|
// Mock Supabase - will be mocked in individual test files
|
|
|
|
// Mock environment variables
|
|
process.env.NEXT_PUBLIC_SUPABASE_URL = 'https://test.supabase.co';
|
|
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY = 'test-anon-key';
|
|
|
|
// Global test utilities
|
|
global.ResizeObserver = jest.fn().mockImplementation(() => ({
|
|
observe: jest.fn(),
|
|
unobserve: jest.fn(),
|
|
disconnect: jest.fn(),
|
|
}));
|
|
|
|
// Mock window.matchMedia
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: jest.fn().mockImplementation(query => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: jest.fn(), // deprecated
|
|
removeListener: jest.fn(), // deprecated
|
|
addEventListener: jest.fn(),
|
|
removeEventListener: jest.fn(),
|
|
dispatchEvent: jest.fn(),
|
|
})),
|
|
});
|
|
|
|
// Mock IntersectionObserver
|
|
global.IntersectionObserver = jest.fn().mockImplementation(() => ({
|
|
observe: jest.fn(),
|
|
unobserve: jest.fn(),
|
|
disconnect: jest.fn(),
|
|
}));
|