fix: PageProps.params never contains arrays, only strings (#91)
This commit is contained in:
+11
-3
@@ -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"));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user