feat: add context information to render function (#46)

This commit is contained in:
Luca Casonato
2021-08-06 18:08:48 +02:00
committed by GitHub
parent 3bce2fb8d3
commit 0777c1c7ba
9 changed files with 116 additions and 61 deletions
+12 -1
View File
@@ -17,13 +17,24 @@ Deno.test("/ page prerender", async () => {
body,
`<script id="__FRSH_PROPS" type="application/json">`,
);
assert(!body.includes(`"params"`));
assertStringIncludes(
body,
`"data":[["home","Hello!"]]`,
);
});
Deno.test("/props/123 page prerender", async () => {
const resp = await router(new Request("https://fresh.deno.dev/props/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,
`{"props":{"params":{"id":"123"},"url":"https://fresh.deno.dev/props/123","route":"/props/:id"}}`,
);
});
Deno.test("/[name] page prerender", async () => {
const resp = await router(new Request("https://fresh.deno.dev/foo"));
assert(resp);