Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
1.7 kB · 54 lines
TypeScript
at next-dev
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import { describe, expect, it } from "vitest";import { notificationHref, notificationTarget} from "#lib/components/notifications/notification.ts";import type { NotificationSummary } from "#lib/components/notifications/types.ts";
const summary = (overrides: Partial<NotificationSummary> = {}): NotificationSummary => ({ uri: "at://did:plc:owner/sh.tangled.repo.issue/abc", type: "issue_created", read: false, createdAt: "2026-01-01T00:00:00.000Z", actor: { did: "did:plc:owner", handle: "alice.test" }, repo: { ownerHandle: "alice.test", name: "core" }, subject: { kind: "issue", uri: "at://did:plc:owner/sh.tangled.repo.issue/abc", number: "abc", title: "a bug" }, ...overrides});
describe("notificationHref", () => { it("links a named repo issue to its owner/repo path", () => { expect(notificationHref(summary())).toBe("/alice.test/core/issues/abc"); });
it("links a repo-only notification to the owner/repo path", () => { expect(notificationHref(summary({ subject: undefined }))).toBe("/alice.test/core"); });
it("links a did-addressed repo by its did, without an owner/name guess", () => { expect( notificationHref( summary({ repo: { ownerHandle: "alice.test", name: "did:plc:abc123" } }) ) ).toBe("/did:plc:abc123"); });
it("falls back to the actor's page when there is no repo", () => { expect(notificationHref(summary({ repo: undefined }))).toBe("/alice.test"); });});
describe("notificationTarget", () => { it("titles a row with owner/repo", () => { expect(notificationTarget(summary())).toBe("alice.test/core"); });
it("leaves a repo-less row untitled", () => { expect(notificationTarget(summary({ repo: undefined }))).toBe(""); });});