aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/serve.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js/serve.test.ts')
-rw-r--r--test/bun.js/serve.test.ts22
1 files changed, 21 insertions, 1 deletions
diff --git a/test/bun.js/serve.test.ts b/test/bun.js/serve.test.ts
index 8961372c1..fb541da24 100644
--- a/test/bun.js/serve.test.ts
+++ b/test/bun.js/serve.test.ts
@@ -1,4 +1,4 @@
-import { file, serve } from "bun";
+import { file, readableStreamToText, serve } from "bun";
import { describe, expect, it } from "bun:test";
import { readFileSync } from "fs";
import { resolve } from "path";
@@ -12,6 +12,26 @@ class TestPass extends Error {
}
}
+describe("request body streaming", () => {
+ it("works", async () => {
+ var server = serve({
+ port: port++,
+ development: false,
+
+ async fetch(req: Request) {
+ const text = await readableStreamToText(req.body);
+ return new Response(text);
+ },
+ });
+
+ var res = await fetch(`http://localhost:${server.port}`, {
+ body: "hello",
+ method: "POST",
+ });
+ expect(await res.text()).toBe("hello");
+ });
+});
+
describe("streaming", () => {
describe("error handler", () => {
it("throw on pull reports an error and close the connection", async () => {