mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:08:27 +00:00
refactor(tui): dedupe handlers and formatter test setup
This commit is contained in:
35
src/tui/commands.test.ts
Normal file
35
src/tui/commands.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getSlashCommands, helpText, parseCommand } from "./commands.js";
|
||||
|
||||
describe("parseCommand", () => {
|
||||
it("normalizes aliases and keeps command args", () => {
|
||||
expect(parseCommand("/elev full")).toEqual({ name: "elevated", args: "full" });
|
||||
});
|
||||
|
||||
it("returns empty name for empty input", () => {
|
||||
expect(parseCommand(" ")).toEqual({ name: "", args: "" });
|
||||
});
|
||||
});
|
||||
|
||||
describe("getSlashCommands", () => {
|
||||
it("provides level completions for built-in toggles", () => {
|
||||
const commands = getSlashCommands();
|
||||
const verbose = commands.find((command) => command.name === "verbose");
|
||||
const activation = commands.find((command) => command.name === "activation");
|
||||
expect(verbose?.getArgumentCompletions?.("o")).toEqual([
|
||||
{ value: "on", label: "on" },
|
||||
{ value: "off", label: "off" },
|
||||
]);
|
||||
expect(activation?.getArgumentCompletions?.("a")).toEqual([
|
||||
{ value: "always", label: "always" },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("helpText", () => {
|
||||
it("includes slash command help for aliases", () => {
|
||||
const output = helpText();
|
||||
expect(output).toContain("/elevated <on|off|ask|full>");
|
||||
expect(output).toContain("/elev <on|off|ask|full>");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user