diff options
author | 2022-03-12 05:54:34 -0800 | |
---|---|---|
committer | 2022-03-12 05:54:34 -0800 | |
commit | 6f39b8f57627b62c4db1a8ee69219b41389b2f96 (patch) | |
tree | e9e3f03215d6b7e23f114adb8723e11cd12ad221 /integration/bunjs-only-snippets/fetch.test.js | |
parent | 7b9312313363e1d63caaef5ec1f98635f2eedd2d (diff) | |
download | bun-6f39b8f57627b62c4db1a8ee69219b41389b2f96.tar.gz bun-6f39b8f57627b62c4db1a8ee69219b41389b2f96.tar.zst bun-6f39b8f57627b62c4db1a8ee69219b41389b2f96.zip |
Response.clone()
Diffstat (limited to 'integration/bunjs-only-snippets/fetch.test.js')
-rw-r--r-- | integration/bunjs-only-snippets/fetch.test.js | 17 |
1 files changed, 16 insertions, 1 deletions
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("<div>hello</div>", { + 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("<div>hello</div>"); + }); +}); |