| 1234567891011121314151617181920212223242526272829303132333435363738 |
- import '@testing-library/jest-dom';
- import { vi } from 'vitest';
- // Mock sonner
- vi.mock('sonner', () => ({
- toast: {
- success: vi.fn(),
- error: vi.fn(),
- warning: vi.fn(),
- info: vi.fn()
- }
- }));
- // Mock scrollIntoView for Radix UI components
- Element.prototype.scrollIntoView = vi.fn();
- // Mock pointer events for Radix UI Select component
- Element.prototype.hasPointerCapture = vi.fn(() => true) as any;
- Element.prototype.releasePointerCapture = vi.fn() as any;
- Element.prototype.setPointerCapture = vi.fn() as any;
- // Mock IntersectionObserver
- global.IntersectionObserver = vi.fn().mockImplementation(() => ({
- observe: vi.fn(),
- unobserve: vi.fn(),
- disconnect: vi.fn()
- })) as any;
- // Mock ResizeObserver (使用 class 模式以支持 Radix UI 的 react-use-size)
- global.ResizeObserver = class MockResizeObserver {
- constructor(callback: ResizeObserverCallback) {
- // Store callback for testing
- (this as any).callback = callback;
- }
- observe() {}
- unobserve() {}
- disconnect() {}
- };
|