/**
 * 测试环境设置
 */
import { expect, afterEach } from "vitest";
import { cleanup } from "@testing-library/react";
import * as matchers from "@testing-library/jest-dom/matchers";

// Mock window.matchMedia for Ant Design components
Object.defineProperty(window, "matchMedia", {
  writable: true,
  value: (query: string) => ({
    matches: false,
    media: query,
    onchange: null,
    addListener: () => {},
    removeListener: () => {},
    addEventListener: () => {},
    removeEventListener: () => {},
    dispatchEvent: () => false,
  }),
});

// 扩展 Vitest 的 expect
expect.extend(matchers);

// 每次测试后清理
afterEach(() => {
  cleanup();
});

// 全局类型声明
declare global {
  // eslint-disable-next-line @typescript-eslint/no-namespace
  namespace Vi {
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    interface Assertion<T = any> extends jest.Matchers<void, T> {}
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    interface AsymmetricMatchersContaining extends jest.Matchers<void, any> {}
  }
}

// 导出空对象以使文件成为模块
export {};
