diff options
Diffstat (limited to 'test/bun.js')
-rw-r--r-- | test/bun.js/serve.test.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/test/bun.js/serve.test.ts b/test/bun.js/serve.test.ts index 9f351e93d..c033aaeb3 100644 --- a/test/bun.js/serve.test.ts +++ b/test/bun.js/serve.test.ts @@ -41,13 +41,35 @@ it("request.url should log successfully", async () => { return new Response(file(fixture)); }, }); - expected = `http://${server.hostname}:${server.port}/helloooo`; + expected = `http://localhost:${server.port}/helloooo`; const response = await fetch(expected); expect(response.url).toBe(expected); expect(await response.text()).toBe(textToExpect); server.stop(); }); +it("request.url should be based on the Host header", async () => { + const fixture = resolve(import.meta.dir, "./fetch.js.txt"); + const textToExpect = readFileSync(fixture, "utf-8"); + var expected; + const server = serve({ + port: port++, + fetch(req) { + expect(req.url).toBe("http://example.com/helloooo"); + return new Response(file(fixture)); + }, + }); + expected = `http://${server.hostname}:${server.port}/helloooo`; + const response = await fetch(expected, { + headers: { + Host: "example.com", + }, + }); + expect(response.url).toBe(expected); + expect(await response.text()).toBe(textToExpect); + server.stop(); +}); + describe("streaming", () => { describe("error handler", () => { it("throw on pull reports an error and close the connection", async () => { |