fix: PageProps.params never contains arrays, only strings (#91)

This commit is contained in:
Leo Kettmeir
2022-02-15 13:24:18 +01:00
committed by GitHub
parent 15f73e3274
commit 2ec980ca45
4 changed files with 40 additions and 15 deletions
+11 -3
View File
@@ -39,20 +39,20 @@ Deno.test("/props/123 page prerender", async () => {
});
Deno.test("/[name] page prerender", async () => {
const resp = await router(new Request("https://fresh.deno.dev/foo"));
const resp = await router(new Request("https://fresh.deno.dev/bar"));
assert(resp);
assertEquals(resp.status, 200);
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
const body = await resp.text();
assertStringIncludes(body, "[name].js");
assertStringIncludes(body, "<div>Hello foo</div>");
assertStringIncludes(body, "<div>Hello bar</div>");
assertStringIncludes(
body,
`<script id="__FRSH_PROPS" type="application/json">`,
);
assertStringIncludes(
body,
`"params":{"name":"foo"}`,
`"params":{"name":"bar"}`,
);
});
@@ -170,3 +170,11 @@ Deno.test("/failure", async () => {
const body = await resp.text();
assert(body.includes("500 internal error: it errored!"));
});
Deno.test("/foo/:path*", async () => {
const resp = await router(new Request("https://fresh.deno.dev/foo/bar/baz"));
assert(resp);
assertEquals(resp.status, 200);
const body = await resp.text();
assert(body.includes("bar/baz"));
});