Something went wrong. Try again.
Monorepo for Tangled
Something went wrong. Try again.
2.1 kB · 66 lines
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667import { describe, expect, it } from "vitest";import { notificationHref, notificationTarget } from "$lib/components/notifications/notification";import type { NotificationSummary } from "$lib/components/notifications/types";
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});
const knotOffer = summary({ type: "knot_invited", knot: { did: "did:web:knot.test", domain: "knot.test" }, repo: undefined, subject: undefined});
describe("notificationHref", () => { it("links a named repo issue to its owner/repo path", () => { expect(notificationHref(summary())).toBe( "/alice.test/core/issues/at://did:plc:owner/sh.tangled.repo.issue/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"); });
it("links knot offer at admin who made it, because knot pages don't exist yet", () => { expect(notificationHref(knotOffer)).toBe("/alice.test"); });
it("links collaboration offer to its repository", () => { expect( notificationHref(summary({ type: "collaborator_invited", subject: undefined })) ).toBe("/alice.test/core"); });});
describe("notificationTarget", () => { it("titles knot offer with knot's domain", () => { expect(notificationTarget(knotOffer)).toBe("knot.test"); });});