Skip to content
26 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Chat and workspace agents: channels, DMs and named agents you talk to1import { test } from "node:test";
2import assert from "node:assert/strict";
3
4import { mentionedHandles, mentions, mentionsColumn } from "./mentions.ts";
5
6test("mentions are found once each, lowercased, in order", () => {
7 assert.deepEqual(mentionedHandles("@Ship can you cut it? cc @syntaqx and @ship"), ["ship", "syntaqx"]);
8 assert.deepEqual(mentionedHandles("(@review-bot) @a_b, @x."), ["review-bot", "a_b", "x"]);
9 assert.deepEqual(mentionedHandles("@ship\n@docs"), ["ship", "docs"]);
10});
11
12test("an email address or a stray @ is not a mention", () => {
13 assert.deepEqual(mentionedHandles("mail me@example.com"), []);
14 assert.deepEqual(mentionedHandles("@ alone, @@double, @-dash"), []);
15 assert.deepEqual(mentionedHandles(""), []);
16});
17
18test("a kept mention matches its whole handle only", () => {
19 const column = mentionsColumn(mentionedHandles("hey @bobby and @ship"));
20 assert.equal(column, " bobby ship ");
21 assert.equal(mentions(column, "bobby"), true);
22 assert.equal(mentions(column, "Ship"), true);
23 assert.equal(mentions(column, "bob"), false);
24 assert.equal(mentions(mentionsColumn([]), "bob"), false);
25 assert.equal(mentions(null, "bob"), false);
26});