import { describe, expect, it } from "vitest"; import { emailInitials, visibleShareReaders, type SharePerson, } from "../../lib/ruleShareTypes"; const readers: SharePerson[] = [ { email: "rosa@example.org", initials: "R", role: "reader" }, { email: "a@example.org", initials: "A", role: "reader" }, { email: "b@example.org", initials: "B", role: "reader" }, ]; describe("visibleShareReaders", () => { it("shows every reader when there is at most one", () => { expect(visibleShareReaders([])).toEqual({ shown: [], overflowCount: 0 }); expect(visibleShareReaders(readers.slice(0, 1))).toEqual({ shown: readers.slice(0, 1), overflowCount: 0, }); }); it("shows the first reader and counts the rest", () => { expect(visibleShareReaders(readers)).toEqual({ shown: readers.slice(0, 1), overflowCount: 2, }); }); }); describe("emailInitials", () => { it("uses the first character of the local part", () => { expect(emailInitials("rosa@example.org")).toBe("R"); expect(emailInitials("")).toBe("?"); }); });