Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233import { describe, expect, it } from "vitest";import type { ReactionRecord } from "#lib/api/reaction.ts";import type { RecordView } from "#lib/api/records.ts";import { buildReactions } from "#lib/components/reaction/reactions.ts";
const reaction = (rkey: string, editor: string, kind = "👍"): RecordView<ReactionRecord> => ({ uri: `at://did:plc:barnacle/org.tangled.feed.reaction/${rkey}`, cid: `bafy${rkey}`, value: { $type: "org.tangled.feed.reaction", subject: { uri: "at://did:plc:barnacle/org.tangled.track.ticket/3lk", cid: "bafyticket" }, reaction: kind, createdAt: "2026-01-01T00:00:00Z", "x-tngl-editor": editor } as ReactionRecord});
describe("buildReactions on knot-hosted reactions", () => { it("counts each writer once and finds the viewer's own reaction", () => { const [group] = buildReactions( [reaction("3aa", "did:plc:limpet"), reaction("3ab", "did:plc:mussel")], "did:plc:mussel" );
expect(group.users.map((user) => user.did)).toEqual(["did:plc:limpet", "did:plc:mussel"]); expect(group.isReacted).toBe(true); expect(group.viewerReaction).toEqual({ uri: "at://did:plc:barnacle/org.tangled.feed.reaction/3ab", cid: "bafy3ab" }); });});