CI / config (push) Canceled after 0s
CI / test-frontend (push) Canceled after 0s
CI / test-rust (push) Canceled after 0s
CI / test-e2e (push) Canceled after 0s
CI / test-e2e-release (push) Canceled after 0s
CI / build (push) Canceled after 0s
CI / release (push) Canceled after 0s
CI / docker (push) Canceled after 0s
CI / docker-website (push) Canceled after 0s
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
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([]);
|
|
});
|