22 lines
718 B
TypeScript
22 lines
718 B
TypeScript
import '@testing-library/jest-dom';
|
|
import { vi } from 'vitest';
|
|
|
|
// Provide a basic matchMedia mock for jsdom so components using media queries
|
|
// (e.g. pointer detection in Tooltip) do not throw during tests.
|
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
if (!window.matchMedia) {
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: vi.fn().mockImplementation((query: string) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: vi.fn(), // deprecated but still used in some libs
|
|
removeListener: vi.fn(),
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
dispatchEvent: vi.fn(),
|
|
})),
|
|
});
|
|
}
|