g1t/apps/web/app/lib/mention.test.ts
| 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; |
| 3 | |
| 4 | import { partialMention } from "./mention.ts"; |
| 5 | |
| 6 | test("an @ that could become @g1t-agent is offered", () => { |
| 7 | assert.equal(partialMention("@", 1), 0); |
| 8 | assert.equal(partialMention("thanks @g1", 10), 7); |
| 9 | assert.equal(partialMention("(@G1T-a", 7), 1); |
| 10 | assert.equal(partialMention("line\n@g1t-agen", 14), 5); |
| 11 | }); |
| 12 | |
| 13 | test("anything else is not", () => { |
| 14 | // Already complete. |
| 15 | assert.equal(partialMention("@g1t-agent", 10), null); |
| 16 | // Another name. |
| 17 | assert.equal(partialMention("@ana", 4), null); |
| 18 | // An email address. |
| 19 | assert.equal(partialMention("me@g1", 5), null); |
| 20 | // The caret is not at the end of it. |
| 21 | assert.equal(partialMention("@g1 later", 9), null); |
| 22 | }); |