fix: ctx.render headers not working (#1927)

This commit is contained in:
Marvin Hagemeister
2023-10-12 23:30:18 +02:00
committed by GitHub
parent 8d90c0ec81
commit bb8921ac85
10 changed files with 165 additions and 2 deletions
+21 -1
View File
@@ -1,4 +1,8 @@
import { assertSelector, parseHtml } from "$fresh/tests/test_utils.ts";
import {
assertSelector,
parseHtml,
withFakeServe,
} from "$fresh/tests/test_utils.ts";
import { assertEquals } from "$std/testing/asserts.ts";
import { createHandler } from "$fresh/server.ts";
import manifest from "./fixture/fresh.gen.ts";
@@ -26,3 +30,19 @@ Deno.test("doesn't leak data across renderers", async () => {
}
await Promise.all(promises);
});
Deno.test("render headers passed to ctx.render()", async () => {
await withFakeServe("./tests/fixture_render/main.ts", async (server) => {
let res = await server.get("/header_arr");
assertEquals(res.headers.get("x-foo"), "Hello world!");
await res.body?.cancel();
res = await server.get("/header_obj");
assertEquals(res.headers.get("x-foo"), "Hello world!");
await res.body?.cancel();
res = await server.get("/header_instance");
assertEquals(res.headers.get("x-foo"), "Hello world!");
await res.body?.cancel();
});
});