From 6f39b8f57627b62c4db1a8ee69219b41389b2f96 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 12 Mar 2022 05:54:34 -0800 Subject: Response.clone() --- integration/bunjs-only-snippets/fetch.test.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'integration/bunjs-only-snippets/fetch.test.js') diff --git a/integration/bunjs-only-snippets/fetch.test.js b/integration/bunjs-only-snippets/fetch.test.js index 72b80cd35..76e09bcf8 100644 --- a/integration/bunjs-only-snippets/fetch.test.js +++ b/integration/bunjs-only-snippets/fetch.test.js @@ -1,4 +1,4 @@ -import { it, describe } from "bun:test"; +import { it, describe, expect } from "bun:test"; import fs from "fs"; describe("fetch", () => { @@ -20,3 +20,18 @@ describe("fetch", () => { }); } }); + +describe("Response", () => { + it("clone", async () => { + var body = new Response("
hello
", { + headers: { + "content-type": "text/html; charset=utf-8", + }, + }); + var clone = body.clone(); + body.headers.set("content-type", "text/plain"); + expect(clone.headers.get("content-type")).toBe("text/html; charset=utf-8"); + expect(body.headers.get("content-type")).toBe("text/plain"); + expect(await clone.text()).toBe("
hello
"); + }); +}); -- cgit v1.2.3