Skip to content

Commit

Permalink
chore: update test to operate on a ReadableStream to ensure cloning d…
Browse files Browse the repository at this point in the history
…oesn't lock the stream for either stream consumer
  • Loading branch information
jacob-ebey committed May 31, 2023
1 parent 400d557 commit 5296801
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/remix-node/__tests__/fetch-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PassThrough } from "stream";
import { ReadableStream } from "@remix-run/web-stream";

import { Request } from "../fetch";

Expand Down Expand Up @@ -70,9 +71,15 @@ let test = {

describe("Request", () => {
it("clones", async () => {
let body = new PassThrough();
test.source.forEach((chunk) => body.write(chunk));
body.end();
let encoder = new TextEncoder();
let body = new ReadableStream({
start(controller) {
test.source.forEach((chunk) => {
controller.enqueue(encoder.encode(chunk));
});
controller.close();
},
});

let req = new Request("http://test.com", {
method: "post",
Expand Down Expand Up @@ -104,7 +111,7 @@ describe("Request", () => {
expect(file.name).toBe("1k_b.dat");
expect(file.size).toBe(1023);

expect(cloned instanceof Request).toBeTruthy()
expect(cloned instanceof Request).toBeTruthy();
});
});

Expand Down

0 comments on commit 5296801

Please sign in to comment.