19 lines · 581 B
import { describe, expect, mock, test } from "bun:test";

mock.module("cloudflare:workers", () => ({ env: {} }));

const { mentionHandles } = await import("./mentions");

describe("mentionHandles", () => {
  test("collects lowercased handles, deduplicated, ignoring emails and paths", () => {
    expect(mentionHandles(["hi @Alice and @bob, mail me at x@alice.dev", "again @alice see /@carol"])).toEqual([
      "alice",
      "bob",
    ]);
  });

  test("team mentions contribute their org handle", () => {
    expect(mentionHandles(["@acme/core"])).toEqual(["acme"]);
  });
});