aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/fetch.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js/fetch.test.js')
-rw-r--r--test/bun.js/fetch.test.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/bun.js/fetch.test.js b/test/bun.js/fetch.test.js
index 9b6093afd..a4ab0bfa6 100644
--- a/test/bun.js/fetch.test.js
+++ b/test/bun.js/fetch.test.js
@@ -255,6 +255,50 @@ describe("Blob", () => {
}
});
+{
+ const sample = new TextEncoder().encode("Hello World!");
+ const typedArrays = [
+ Uint8Array,
+ Uint8ClampedArray,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Float32Array,
+ Float64Array,
+ ];
+ const Constructors = [Blob, Response, Request];
+
+ for (let withGC of [false, true]) {
+ for (let TypedArray of typedArrays) {
+ for (let Constructor of Constructors) {
+ it(`${Constructor.name} arrayBuffer() with ${TypedArray.name}${
+ withGC ? " with gc" : ""
+ }`, async () => {
+ const data = new TypedArray(sample);
+ if (withGC) gc();
+ const input =
+ Constructor === Blob
+ ? [data]
+ : Constructor === Request
+ ? { body: data }
+ : data;
+ if (withGC) gc();
+ const blob = new Constructor(input);
+ if (withGC) gc();
+ const out = await blob.arrayBuffer();
+ if (withGC) gc();
+ expect(out instanceof ArrayBuffer).toBe(true);
+ if (withGC) gc();
+ expect(out.byteLength).toBe(data.byteLength);
+ if (withGC) gc();
+ });
+ }
+ }
+ }
+}
+
describe("Response", () => {
describe("Response.json", () => {
it("works", async () => {