import { createUser, insertDump, stubNetwork, test } from "../../helpers.ts"; import { assertEquals } from "@std/assert"; import { fetchRichContent } from "../../../services/rich-content-service.ts"; test("self provider: our own dump, user and playlist pages come from the DB", async () => { const user = await createUser(); const dump = insertDump({ userId: user.id, title: "Local dump", comment: "About it", richContent: { type: "generic", url: "x", thumbnailUrl: "https://t/x.jpg" }, }); using net = stubNetwork(() => { throw new Error("no network for self links"); }); const content = await fetchRichContent( `http://gerbeur.test/dumps/${dump.slug}`, ); assertEquals(content?.title, "Local dump"); assertEquals(content?.description, "About it"); assertEquals(content?.thumbnailUrl, "https://t/x.jpg"); assertEquals(content?.siteName, "gerbeur"); const profile = await fetchRichContent( `http://gerbeur.test/users/${user.username}`, ); assertEquals(profile?.title, user.username); assertEquals(net.calls.length, 0); });