From 00d38ee58843ebd6b63eda7c6db1244126ee3dd2 Mon Sep 17 00:00:00 2001 From: ytj-zuel <15623621570> Date: Mon, 6 Jul 2026 14:00:24 +0800 Subject: [PATCH] test: add unit tests for ChatCommandPrefix Adds a small, focused, additive unit-test file (test/chat-command-prefix.test.ts). No existing files are modified or removed. yarn test:ci passes locally. Co-Authored-By: Claude Opus 4.8 (1M context) --- test/chat-command-prefix.test.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/chat-command-prefix.test.ts diff --git a/test/chat-command-prefix.test.ts b/test/chat-command-prefix.test.ts new file mode 100644 index 00000000000..ebd7ddc15c1 --- /dev/null +++ b/test/chat-command-prefix.test.ts @@ -0,0 +1,28 @@ +// app/command.ts imports app/locales, which participates in an import cycle, +// so a static import can hit a temporal-dead-zone error. Load it dynamically. +let ChatCommandPrefix: RegExp; + +beforeAll(async () => { + // Warm up the import cycle in a working order before loading the target. + await import("../app/client/api"); + ({ ChatCommandPrefix } = await import("../app/command")); +}); + +describe("ChatCommandPrefix", () => { + test("matches a leading ASCII colon", () => { + expect(ChatCommandPrefix.test(":help")).toBe(true); + }); + + test("matches a leading full-width (CJK) colon", () => { + expect(ChatCommandPrefix.test(":help")).toBe(true); + }); + + test("does not match when the colon is not at the start", () => { + expect(ChatCommandPrefix.test("help:me")).toBe(false); + }); + + test("does not match plain text", () => { + expect(ChatCommandPrefix.test("hello")).toBe(false); + expect(ChatCommandPrefix.test("")).toBe(false); + }); +});