Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

728 B
Raw Blame
import { describe, expect, it } from "vitest";
import { extractMentionUsernames } from "@/lib/memo-markdown";

describe("extractMentionUsernames", () => {
  it("uses the same Markdown contexts and exact spelling as rendering", () => {
    expect(
      extractMentionUsernames("**@Alice** ~~@bob~~ `@code` [@link](/x) ![@image](/x) https://example.com/@url $@math$ @Alice"),
    ).toEqual(["Alice", "bob"]);
  });

  it("keeps escapes and GFM emails opaque", () => {
    expect(extractMentionUsernames("\\@escaped @[email protected] @ok")).toEqual(["ok"]);
  });

  it("keeps case-distinct username references distinct", () => {
    expect(extractMentionUsernames("@Alice @alice @Alice")).toEqual(["Alice", "alice"]);
  });
});