51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
// 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(),
|
|
back: jest.fn(),
|
|
}),
|
|
usePathname: () => '/dashboard',
|
|
useSearchParams: () => new URLSearchParams(),
|
|
}))
|
|
|
|
// Mock window.location
|
|
if (typeof window !== 'undefined') {
|
|
delete window.location;
|
|
window.location = {
|
|
origin: 'http://localhost:3000',
|
|
href: 'http://localhost:3000/dashboard',
|
|
reload: jest.fn(),
|
|
};
|
|
}
|
|
|
|
// Mock localStorage
|
|
const localStorageMock = {
|
|
getItem: jest.fn(),
|
|
setItem: jest.fn(),
|
|
removeItem: jest.fn(),
|
|
clear: jest.fn(),
|
|
}
|
|
global.localStorage = localStorageMock
|
|
|
|
// Mock sessionStorage
|
|
const sessionStorageMock = {
|
|
getItem: jest.fn(),
|
|
setItem: jest.fn(),
|
|
removeItem: jest.fn(),
|
|
clear: jest.fn(),
|
|
}
|
|
global.sessionStorage = sessionStorageMock
|
|
|
|
// Suppress console errors in tests unless needed
|
|
global.console = {
|
|
...console,
|
|
error: jest.fn(),
|
|
warn: jest.fn(),
|
|
}
|
|
|