diff options
author | 2022-12-12 20:58:28 -0600 | |
---|---|---|
committer | 2022-12-12 18:58:28 -0800 | |
commit | 9f9db85a946dfc3c0a2075cc49e58fca5aab0ad3 (patch) | |
tree | 6a80884b585c455e40ca35788e346c69f9eaebe4 /test | |
parent | bbc2dacd840709f2fdf932ae27c978078f348ac6 (diff) | |
download | bun-9f9db85a946dfc3c0a2075cc49e58fca5aab0ad3.tar.gz bun-9f9db85a946dfc3c0a2075cc49e58fca5aab0ad3.tar.zst bun-9f9db85a946dfc3c0a2075cc49e58fca5aab0ad3.zip |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/bun.js/node-stream.test.js | 28 |
1 files changed, 27 insertions, 1 deletions
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", () => { |