/**
 * Vitest 全局测试环境配置
 *
 * - 注册 @testing-library/jest-dom 自定义匹配器
 * - 提供 jsdom 环境下的 localStorage / fetch mock
 */
import "@testing-library/jest-dom/vitest";
import { afterEach, beforeEach, vi } from "vitest";
import { cleanup } from "@testing-library/react";

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

// 每个测试前重置 localStorage
beforeEach(() => {
  localStorage.clear();
});

// mock fetch（用于 auth.ts login 测试）
global.fetch = vi.fn() as unknown as typeof fetch;
