MiniSearch / client /setupTests.ts
github-actions[bot]
Sync from https://github.com/felladrin/MiniSearch
00443a6
import "@testing-library/jest-dom";
import { vi } from "vitest";
Object.defineProperty(window, "matchMedia", {
writable: true,
value: vi.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(),
removeListener: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
})),
});
class ResizeObserverMock {
observe = vi.fn();
unobserve = vi.fn();
disconnect = vi.fn();
}
vi.stubGlobal("ResizeObserver", ResizeObserverMock);
class IntersectionObserverMock {
root = null;
rootMargin = "";
thresholds = [];
observe = vi.fn();
unobserve = vi.fn();
disconnect = vi.fn();
takeRecords = vi.fn().mockReturnValue([]);
}
vi.stubGlobal("IntersectionObserver", IntersectionObserverMock);