import { expect, it, vi } from "vitest"; import { createBobbinClient } from "$lib/api/client"; import { FOLLOW_VIEWER, STAR_VIEWER } from "$lib/api/descriptors"; import { TYPE_VIEWER } from "$lib/api/enrich"; import { getTrendingWithViewerState } from "$lib/api/profile"; it("gets viewer-neutral trending data with relationship state in the enrichment sidecar", async () => { const fetchMock = vi.fn().mockResolvedValue( new Response(JSON.stringify({ output: { people: [], repos: [] }, data: {} }), { status: 200, headers: { "content-type": "application/json" } }) ); const ctx = createBobbinClient({ serviceUrl: "https://bobbin.test", fetch: fetchMock }); await getTrendingWithViewerState(ctx, "did:plc:viewer"); const [url, request] = fetchMock.mock.calls[0]; expect(String(url)).toBe("https://bobbin.test/xrpc/sh.tangled.query.enrichResponse"); expect(JSON.parse(String(request?.body))).toEqual({ xrpc: "sh.tangled.actor.getTrending", viewer: "did:plc:viewer", enrich: [ { source: FOLLOW_VIEWER.source, type: TYPE_VIEWER, targets: ["people[].did"] }, { source: STAR_VIEWER.source, type: TYPE_VIEWER, targets: ["repos[].did"] } ] }); });