mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-04 03:25:21 +00:00
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
![]() |
import '@testing-library/jest-dom'
|
||
|
import { vi } from 'vitest'
|
||
|
|
||
|
// Mock i18next for tests
|
||
|
vi.mock('react-i18next', () => ({
|
||
|
useTranslation: () => ({
|
||
|
t: (key: string) => key,
|
||
|
i18n: {
|
||
|
changeLanguage: vi.fn(),
|
||
|
},
|
||
|
}),
|
||
|
initReactI18next: {
|
||
|
type: '3rdParty',
|
||
|
init: vi.fn(),
|
||
|
},
|
||
|
I18nextProvider: ({ children }: { children: React.ReactNode }) => children,
|
||
|
}));
|
||
|
|
||
|
// Mock i18next-http-backend
|
||
|
vi.mock('i18next-http-backend', () => ({
|
||
|
default: {
|
||
|
type: 'backend',
|
||
|
init: vi.fn(),
|
||
|
read: vi.fn(),
|
||
|
save: vi.fn(),
|
||
|
},
|
||
|
}));
|
||
|
|
||
|
// Mock window.URL.createObjectURL and revokeObjectURL for tests
|
||
|
global.URL.createObjectURL = vi.fn(() => 'mocked-url')
|
||
|
global.URL.revokeObjectURL = vi.fn()
|
||
|
|
||
|
// Mock Worker for tests (Web Workers not available in test environment)
|
||
|
global.Worker = vi.fn().mockImplementation(() => ({
|
||
|
postMessage: vi.fn(),
|
||
|
terminate: vi.fn(),
|
||
|
addEventListener: vi.fn(),
|
||
|
removeEventListener: vi.fn(),
|
||
|
}))
|
||
|
|
||
|
// Mock ResizeObserver for Mantine components
|
||
|
global.ResizeObserver = vi.fn().mockImplementation(() => ({
|
||
|
observe: vi.fn(),
|
||
|
unobserve: vi.fn(),
|
||
|
disconnect: vi.fn(),
|
||
|
}))
|
||
|
|
||
|
// Mock IntersectionObserver for components that might use it
|
||
|
global.IntersectionObserver = vi.fn().mockImplementation(() => ({
|
||
|
observe: vi.fn(),
|
||
|
unobserve: vi.fn(),
|
||
|
disconnect: vi.fn(),
|
||
|
}))
|
||
|
|
||
|
// Mock matchMedia for responsive components
|
||
|
Object.defineProperty(window, 'matchMedia', {
|
||
|
writable: true,
|
||
|
value: vi.fn().mockImplementation(query => ({
|
||
|
matches: false,
|
||
|
media: query,
|
||
|
onchange: null,
|
||
|
addListener: vi.fn(), // deprecated
|
||
|
removeListener: vi.fn(), // deprecated
|
||
|
addEventListener: vi.fn(),
|
||
|
removeEventListener: vi.fn(),
|
||
|
dispatchEvent: vi.fn(),
|
||
|
})),
|
||
|
})
|