feat: add core UI components and baseline tests

This commit is contained in:
2026-03-19 16:56:27 +08:00
parent 12642e0a92
commit 063179933c
73 changed files with 5756 additions and 2 deletions
+64
View File
@@ -0,0 +1,64 @@
import "@testing-library/jest-dom/vitest";
import { cleanup } from "@testing-library/react";
import { afterEach, vi } from "vitest";
afterEach(() => {
cleanup();
});
class ResizeObserverMock {
observe() {}
unobserve() {}
disconnect() {}
}
class PointerEventMock extends MouseEvent {
constructor(type: string, props: PointerEventInit = {}) {
super(type, props);
}
}
Object.defineProperty(window, "matchMedia", {
writable: true,
value: vi.fn().mockImplementation((query: string) => ({
matches: false,
media: query,
onchange: null,
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
addListener: vi.fn(),
removeListener: vi.fn(),
dispatchEvent: vi.fn()
}))
});
Object.defineProperty(window, "ResizeObserver", {
writable: true,
value: ResizeObserverMock
});
Object.defineProperty(window, "PointerEvent", {
writable: true,
value: PointerEventMock
});
Object.defineProperty(window.HTMLElement.prototype, "scrollIntoView", {
configurable: true,
value: vi.fn()
});
Object.defineProperty(window.HTMLElement.prototype, "hasPointerCapture", {
configurable: true,
value: vi.fn(() => false)
});
Object.defineProperty(window.HTMLElement.prototype, "releasePointerCapture", {
configurable: true,
value: vi.fn()
});
Object.defineProperty(window.HTMLElement.prototype, "setPointerCapture", {
configurable: true,
value: vi.fn()
});