mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 22:05:50 +00:00
- errors.test.ts: 28 tests (isAbortError, toError, errorMessage, getErrnoCode, isFsInaccessible, classifyAxiosError 等) - shellRuleMatching.test.ts: 22 tests (permissionRuleExtractPrefix, hasWildcards, matchWildcardPattern, parsePermissionRule 等) - argumentSubstitution.test.ts: 18 tests (parseArguments, parseArgumentNames, generateProgressiveArgumentHint, substituteArguments) - CircularBuffer.test.ts: 12 tests (add, addAll, getRecent, toArray, clear, length) - sanitization.test.ts: 14 tests (partiallySanitizeUnicode, recursivelySanitizeUnicode) - slashCommandParsing.test.ts: 8 tests (parseSlashCommand) - contentArray.test.ts: 6 tests (insertBlockAfterToolResults) - objectGroupBy.test.ts: 5 tests (objectGroupBy) 总计:781 tests / 40 files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { parseSlashCommand } from "../slashCommandParsing";
|
|
|
|
describe("parseSlashCommand", () => {
|
|
test("parses simple command", () => {
|
|
const result = parseSlashCommand("/search foo bar");
|
|
expect(result).toEqual({
|
|
commandName: "search",
|
|
args: "foo bar",
|
|
isMcp: false,
|
|
});
|
|
});
|
|
|
|
test("parses command without args", () => {
|
|
const result = parseSlashCommand("/help");
|
|
expect(result).toEqual({
|
|
commandName: "help",
|
|
args: "",
|
|
isMcp: false,
|
|
});
|
|
});
|
|
|
|
test("parses MCP command", () => {
|
|
const result = parseSlashCommand("/tool (MCP) arg1 arg2");
|
|
expect(result).toEqual({
|
|
commandName: "tool (MCP)",
|
|
args: "arg1 arg2",
|
|
isMcp: true,
|
|
});
|
|
});
|
|
|
|
test("parses MCP command without args", () => {
|
|
const result = parseSlashCommand("/tool (MCP)");
|
|
expect(result).toEqual({
|
|
commandName: "tool (MCP)",
|
|
args: "",
|
|
isMcp: true,
|
|
});
|
|
});
|
|
|
|
test("returns null for non-slash input", () => {
|
|
expect(parseSlashCommand("hello")).toBeNull();
|
|
});
|
|
|
|
test("returns null for empty string", () => {
|
|
expect(parseSlashCommand("")).toBeNull();
|
|
});
|
|
|
|
test("returns null for just slash", () => {
|
|
expect(parseSlashCommand("/")).toBeNull();
|
|
});
|
|
|
|
test("trims whitespace before parsing", () => {
|
|
const result = parseSlashCommand(" /search foo ");
|
|
expect(result!.commandName).toBe("search");
|
|
expect(result!.args).toBe("foo");
|
|
});
|
|
});
|