Files
bun.sh/test/js/web/fetch/fetch.brotli.test.ts
2024-09-03 21:32:52 -07:00

26 lines
655 B
TypeScript

import { expect, test } from "bun:test";
test("fetch brotli response works", async () => {
const [firstText, secondText, { headers }] = await Promise.all([
fetch("https://bun.sh/logo.svg", {
headers: {
"Accept-Encoding": "br",
},
}).then(res => res.text()),
fetch("https://bun.sh/logo.svg", {
headers: {
"Accept-Encoding": "gzip",
},
}).then(res => res.text()),
fetch("https://bun.sh/logo.svg", {
headers: {
"Accept-Encoding": "br",
},
decompress: false,
}),
]);
expect(firstText).toBe(secondText);
expect(headers.get("Content-Encoding")).toBe("br");
});