import { BASE_URL, createUser, db, insertDump, insertPlaylist, test, } from "../helpers.ts"; import { assertEquals, assertFalse, assertStringIncludes } from "@std/assert"; import { Application } from "@oak/oak"; import { ogMiddleware } from "../../middleware/og.ts"; async function handle( app: Application, path: string, headers: HeadersInit = {}, ) { const res = await app.handle(new Request(`${BASE_URL}${path}`, { headers })); if (!res) throw new Error("no response"); return { res, text: await res.text() }; } function ogApp() { const app = new Application(); app.use(ogMiddleware); app.use((ctx) => { ctx.response.body = "fallthrough"; }); return app; } test("ogMiddleware: dump pages get escaped OG tags", async () => { const user = await createUser(); const dump = insertDump({ userId: user.id, title: `Tom & "Jerry"