New Rules stay off lists until the person who holds the pen turns on a share link, or the team features one. Uploaded files are readable only by those readers, stripped of location metadata, and deleted with the Rule, draft, or account.
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
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("?");
|
|
});
|
|
});
|