forked from bai/curriculum-project-hub
18 lines
941 B
TypeScript
18 lines
941 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { parseSlashHelpSubcommand, parseSlashInvocation } from "../../src/feishu/slashCommands.js";
|
|
|
|
describe("slash command parser", () => {
|
|
it("parses a slash invocation without resolving it", () => {
|
|
expect(parseSlashInvocation("/new")).toEqual({ name: "new", args: [] });
|
|
expect(parseSlashInvocation("/review 看看这节")).toEqual({ name: "review", args: ["看看这节"] });
|
|
expect(parseSlashInvocation("写教案")).toBeNull();
|
|
});
|
|
|
|
it("parses help subcommands only in the exact /<command> help form", () => {
|
|
expect(parseSlashHelpSubcommand({ name: "new", args: ["help"] })).toBe("new");
|
|
expect(parseSlashHelpSubcommand({ name: "unknown", args: ["help"] })).toBe("unknown");
|
|
expect(parseSlashHelpSubcommand({ name: "new", args: ["help", "please"] })).toBeNull();
|
|
expect(parseSlashHelpSubcommand({ name: "help", args: ["new"] })).toBeNull();
|
|
});
|
|
});
|