64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
||
import {
|
||
clipCommunityInviteDescription,
|
||
communityInviteInitials,
|
||
communityPossessive,
|
||
inviteRuleCountsLabel,
|
||
} from "../../lib/create/ruleInviteCardMeta";
|
||
|
||
describe("communityInviteInitials", () => {
|
||
it("uses the first two words", () => {
|
||
expect(communityInviteInitials("Juniper Street Food Share")).toBe("JS");
|
||
});
|
||
|
||
it("uses two letters of a single word", () => {
|
||
expect(communityInviteInitials("Garden")).toBe("GA");
|
||
});
|
||
});
|
||
|
||
describe("communityPossessive", () => {
|
||
it("adds a curly ’s when the name does not end in s", () => {
|
||
expect(communityPossessive("Juniper Street Food Share")).toBe(
|
||
"Juniper Street Food Share’s",
|
||
);
|
||
});
|
||
|
||
it("adds only a curly apostrophe when the name ends in s", () => {
|
||
expect(communityPossessive("Members")).toBe("Members’");
|
||
});
|
||
});
|
||
|
||
describe("clipCommunityInviteDescription", () => {
|
||
it("cuts at 140 characters", () => {
|
||
const long = "a".repeat(160);
|
||
expect(clipCommunityInviteDescription(long)).toHaveLength(140);
|
||
});
|
||
});
|
||
|
||
describe("inviteRuleCountsLabel", () => {
|
||
it("counts values and other cards, not shared terms", () => {
|
||
expect(
|
||
inviteRuleCountsLabel({
|
||
sections: [
|
||
{
|
||
categoryName: "Values",
|
||
entries: [
|
||
{ title: "Care", body: "We care." },
|
||
{ title: "Share", body: "We share." },
|
||
{ title: "Listen", body: "We listen." },
|
||
],
|
||
},
|
||
{
|
||
categoryName: "Communication",
|
||
entries: [{ title: "Open channel", body: "We talk in the hall." }],
|
||
},
|
||
{
|
||
categoryName: "Membership",
|
||
entries: [{ title: "Open admission", body: "Anyone who shares the work." }],
|
||
},
|
||
],
|
||
}),
|
||
).toBe("3 VALUES AND 2 CARDS");
|
||
});
|
||
});
|