Router cleanup (#2099)

This commit is contained in:
Marvin Hagemeister
2023-11-30 14:08:05 +01:00
committed by GitHub
parent a0a756a1ec
commit 8ddc21eb90
15 changed files with 398 additions and 496 deletions
+39 -38
View File
@@ -58,47 +58,48 @@ Deno.test({
},
});
Deno.test({
name: "passes context to server component",
Deno.test("passes context to server component", async () => {
await withFresh(
"./tests/fixture_server_components/main.ts",
async (address) => {
const res = await fetch(`${address}/context/foo`);
const json = await res.json();
async fn() {
await withFresh(
"./tests/fixture_server_components/main.ts",
async (address) => {
const res = await fetch(`${address}/context/foo`);
const json = await res.json();
assertEquals(typeof json.localAddr, "object");
assertEquals(typeof json.remoteAddr, "object");
json.localAddr.port = 8000;
json.remoteAddr.port = 8000;
assertEquals(typeof json.localAddr, "object");
assertEquals(typeof json.remoteAddr, "object");
json.localAddr.port = 8000;
json.remoteAddr.port = 8000;
assertEquals(
json,
{
localAddr: {
hostname: "localhost",
port: 8000,
transport: "tcp",
},
remoteAddr: {
hostname: "127.0.0.1",
port: 8000,
transport: "tcp",
},
renderNotFound: "AsyncFunction",
url: `${address}/context/foo`,
route: "/context/:id",
params: {
id: "foo",
},
state: {},
isPartial: false,
assertEquals(
json,
{
localAddr: {
hostname: "localhost",
port: 8000,
transport: "tcp",
},
);
},
);
},
remoteAddr: {
hostname: "127.0.0.1",
port: 8000,
transport: "tcp",
},
render: "AsyncFunction",
Component: "Function",
destination: "route",
next: "Function",
basePath: "",
renderNotFound: "AsyncFunction",
url: `${address}/context/foo`,
route: "/context/:id",
params: {
id: "foo",
},
state: {},
isPartial: false,
},
);
},
);
});
Deno.test({