From 9f9db85a946dfc3c0a2075cc49e58fca5aab0ad3 Mon Sep 17 00:00:00 2001 From: Derrick Farris Date: Mon, 12 Dec 2022 20:58:28 -0600 Subject: fix(stream): Fix Readable.pipe() (#1606) * fix(stream): fix some debug logs that were breaking .pipe * fix(stream): another debug fix * test(stream): add test for .pipe --- test/bun.js/node-stream.test.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'test/bun.js/node-stream.test.js') diff --git a/test/bun.js/node-stream.test.js b/test/bun.js/node-stream.test.js index 8024ab562..549f7c180 100644 --- a/test/bun.js/node-stream.test.js +++ b/test/bun.js/node-stream.test.js @@ -1,5 +1,31 @@ import { expect, describe, it } from "bun:test"; -import { Duplex, Transform, PassThrough } from "node:stream"; +import { + Readable, + Writable, + Duplex, + Transform, + PassThrough, +} from "node:stream"; + +describe("Readable", () => { + it("should be able to be piped via .pipe", () => { + const readable = new Readable({ + _read() { + this.push("Hello World!"); + this.push(null); + }, + }); + + const writable = new Writable({ + _write(chunk, encoding, callback) { + expect(chunk.toString()).toBe("Hello World!"); + callback(); + }, + }); + + readable.pipe(writable); + }); +}); describe("Duplex", () => { it("should allow subclasses to be derived via .call() on class", () => { -- cgit v1.2.3