2026-05-16 18:21:37 +08:00
|
|
|
import { describe, expect, it } from "vitest";
|
2026-05-28 15:49:08 +08:00
|
|
|
import { categoryCardLines, cleanCategoryDisplayName } from "./categoryDisplay";
|
|
|
|
|
|
|
|
|
|
describe("cleanCategoryDisplayName", () => {
|
|
|
|
|
it("removes parenthetical suffixes used as backend qualifiers", () => {
|
|
|
|
|
expect(cleanCategoryDisplayName("官方公告(繁中)")).toBe("官方公告");
|
|
|
|
|
expect(cleanCategoryDisplayName("Tutorials (EN)")).toBe("Tutorials");
|
|
|
|
|
expect(cleanCategoryDisplayName("补贴政策\r")).toBe("补贴政策");
|
|
|
|
|
});
|
|
|
|
|
});
|
2026-05-16 18:21:37 +08:00
|
|
|
|
|
|
|
|
describe("categoryCardLines", () => {
|
|
|
|
|
it("splits Chinese and ASCII parenthetical subtitles", () => {
|
|
|
|
|
expect(categoryCardLines("官方公告(繁中)")).toEqual({
|
|
|
|
|
line1: "官方公告",
|
|
|
|
|
line2: "(繁中)",
|
|
|
|
|
});
|
|
|
|
|
expect(categoryCardLines("Tutorials (EN)")).toEqual({
|
|
|
|
|
line1: "Tutorials",
|
|
|
|
|
line2: "(EN)",
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("uses trimmed description as subtitle when name has no parentheses", () => {
|
|
|
|
|
expect(categoryCardLines("影片", " 官方教學 ")).toEqual({
|
|
|
|
|
line1: "影片",
|
|
|
|
|
line2: "官方教學",
|
|
|
|
|
});
|
|
|
|
|
expect(categoryCardLines("文件")).toEqual({ line1: "文件" });
|
|
|
|
|
});
|
|
|
|
|
});
|