import { ServerContext } from "../server.ts"; import { assert, assertEquals, assertStringIncludes } from "./deps.ts"; import routes from "./fixture/routes.gen.ts"; const ctx = await ServerContext.fromRoutes(routes); const router = ctx.handler(); Deno.test("/ page prerender", async () => { const resp = await router(new Request("https://fresh.deno.dev/")); assert(resp); assertEquals(resp.status, 200); assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8"); const body = await resp.text(); assertStringIncludes(body, ``); assertStringIncludes(body, "index.js"); assertStringIncludes(body, "
Hello!
"); assertStringIncludes(body, "Viewing JIT render.
"); assertStringIncludes( body, ``)); assertStringIncludes(body, "This is a static page.
"); assert(!body.includes("__FRSH_PROPS")); }); Deno.test("/books/:id page - /books/123", async () => { const resp = await router(new Request("https://fresh.deno.dev/books/123")); assert(resp); assertEquals(resp.status, 200); assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8"); const body = await resp.text(); assertStringIncludes(body, "