72 lines
2.2 KiB
TypeScript
72 lines
2.2 KiB
TypeScript
/**
|
||
* 平台映射统一测试
|
||
* 验证 platforms.ts 作为唯一真实来源
|
||
*/
|
||
|
||
import { describe, it, expect } from "vitest";
|
||
import { PLATFORM_MAP, PLATFORMS } from "@/lib/platforms";
|
||
|
||
describe("PLATFORM_MAP 统一平台映射", () => {
|
||
const EXPECTED_PLATFORMS = [
|
||
"wenxin",
|
||
"kimi",
|
||
"tongyi",
|
||
"baidu_ai",
|
||
"yuanbao",
|
||
"qingyan",
|
||
"doubao",
|
||
"tiangong",
|
||
"xinghuo",
|
||
] as const;
|
||
|
||
it("PLATFORM_MAP 应包含全部9个平台", () => {
|
||
const keys = Object.keys(PLATFORM_MAP);
|
||
expect(keys).toHaveLength(9);
|
||
});
|
||
|
||
it("PLATFORM_MAP 应包含所有预期的平台键", () => {
|
||
for (const platform of EXPECTED_PLATFORMS) {
|
||
expect(PLATFORM_MAP).toHaveProperty(platform);
|
||
}
|
||
});
|
||
|
||
it("PLATFORM_MAP 必须包含 baidu_ai 和 yuanbao(dashboard-health.ts 的 PLATFORM_LABELS 缺失的)", () => {
|
||
expect(PLATFORM_MAP).toHaveProperty("baidu_ai");
|
||
expect(PLATFORM_MAP).toHaveProperty("yuanbao");
|
||
expect(PLATFORM_MAP["baidu_ai"]).toBe("百度AI搜索");
|
||
expect(PLATFORM_MAP["yuanbao"]).toBe("腾讯元宝");
|
||
});
|
||
|
||
it("每个平台的 label 应为非空字符串", () => {
|
||
for (const [key, label] of Object.entries(PLATFORM_MAP)) {
|
||
expect(label).toBeTruthy();
|
||
expect(typeof label).toBe("string");
|
||
expect(label.length).toBeGreaterThan(0);
|
||
}
|
||
});
|
||
|
||
it("PLATFORMS 数组应与 PLATFORM_MAP 键一致", () => {
|
||
const platformKeys = PLATFORMS.map((p) => p.key);
|
||
const mapKeys = Object.keys(PLATFORM_MAP);
|
||
expect(platformKeys.sort()).toEqual(mapKeys.sort());
|
||
});
|
||
|
||
it("PLATFORMS 数组中每个条目的 label 应与 PLATFORM_MAP 一致", () => {
|
||
for (const platform of PLATFORMS) {
|
||
expect(platform.label).toBe(PLATFORM_MAP[platform.key]);
|
||
}
|
||
});
|
||
});
|
||
|
||
describe("dashboard-health.ts 不再定义自己的 PLATFORM_LABELS", () => {
|
||
it("dashboard-health.ts 不应导出 PLATFORM_LABELS", async () => {
|
||
const dashboardHealthModule = await import("@/types/dashboard-health");
|
||
expect("PLATFORM_LABELS" in dashboardHealthModule).toBe(false);
|
||
});
|
||
|
||
it("dashboard-health.ts 不应导出 PLATFORM_ICONS", async () => {
|
||
const dashboardHealthModule = await import("@/types/dashboard-health");
|
||
expect("PLATFORM_ICONS" in dashboardHealthModule).toBe(false);
|
||
});
|
||
});
|