mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-03 05:10:16 +03:00
# Description of Changes Originally, I wanted to re-enable typed linting on our repo but using Oxlint this time to avoid the memory and speed issues that ESLint was causing. Unfortunately, it's not stable enough yet to actually use on our repo (although it is close, I suspect it'll be stable enough fairly soon). I was able to remove many of the unnecessary casts that it found though, so even though this won't be enforced, it's still worth cleaning up what I've found.
68 lines
1.5 KiB
TypeScript
68 lines
1.5 KiB
TypeScript
import "@testing-library/jest-dom";
|
|
import { vi } from "vitest";
|
|
|
|
// The shims `src/index.tsx` installs - see core/setupTests.ts.
|
|
import "@app/utils/engineShims";
|
|
|
|
// Mirrors the editor's setup: jsdom lacks a handful of browser APIs that shared
|
|
// components (Mantine FocusTrap, responsive helpers) touch on render.
|
|
|
|
class LocalStorageMock implements Storage {
|
|
private store: Record<string, string> = {};
|
|
|
|
get length(): number {
|
|
return Object.keys(this.store).length;
|
|
}
|
|
|
|
clear(): void {
|
|
this.store = {};
|
|
}
|
|
|
|
getItem(key: string): string | null {
|
|
return this.store[key] ?? null;
|
|
}
|
|
|
|
key(index: number): string | null {
|
|
return Object.keys(this.store)[index] ?? null;
|
|
}
|
|
|
|
removeItem(key: string): void {
|
|
delete this.store[key];
|
|
}
|
|
|
|
setItem(key: string, value: string): void {
|
|
this.store[key] = value;
|
|
}
|
|
}
|
|
|
|
Object.defineProperty(window, "localStorage", {
|
|
value: new LocalStorageMock(),
|
|
writable: true,
|
|
});
|
|
|
|
global.ResizeObserver = vi.fn().mockImplementation(() => ({
|
|
observe: vi.fn(),
|
|
unobserve: vi.fn(),
|
|
disconnect: vi.fn(),
|
|
}));
|
|
|
|
global.IntersectionObserver = vi.fn().mockImplementation(() => ({
|
|
observe: vi.fn(),
|
|
unobserve: vi.fn(),
|
|
disconnect: vi.fn(),
|
|
}));
|
|
|
|
Object.defineProperty(window, "matchMedia", {
|
|
writable: true,
|
|
value: vi.fn().mockImplementation((query: string) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: vi.fn(),
|
|
removeListener: vi.fn(),
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
dispatchEvent: vi.fn(),
|
|
})),
|
|
});
|