import { expect, test } from "vitest"; import type { Command } from "../types/command.ts"; import { fuzzySearchAndSort } from "../lib/fuzzy_search.ts"; import { commandOptions } from "./command_palette.tsx"; test("shows Chinese labels while preserving registered command IDs", () => { const command = { name: "Editor: Toggle Dark Mode" } as Command; const options = commandOptions(new Map([[command.name, command]])); expect(options).toMatchObject([ { name: "编辑器:切换深色模式", description: "Editor: Toggle Dark Mode", meta: { commandName: "Editor: Toggle Dark Mode", aliases: ["Editor: Toggle Dark Mode"], }, }, ]); }); test("finds translated commands using either Chinese or English", () => { const command = { name: "Editor: Toggle Dark Mode" } as Command; const options = commandOptions(new Map([[command.name, command]])); expect(fuzzySearchAndSort(options, "深色")).toHaveLength(1); expect(fuzzySearchAndSort(options, "toggle dark")).toHaveLength(1); }); test("omits hidden commands", () => { const command = { name: "Navigate: To Page", hide: true, } as Command; expect(commandOptions(new Map([[command.name, command]]))).toEqual([]); });