Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions test/chat-command-prefix.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
Loading