aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/node-stream.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js/node-stream.test.js')
-rw-r--r--test/bun.js/node-stream.test.js25
1 files changed, 22 insertions, 3 deletions
diff --git a/test/bun.js/node-stream.test.js b/test/bun.js/node-stream.test.js
index 549f7c180..afa1867b6 100644
--- a/test/bun.js/node-stream.test.js
+++ b/test/bun.js/node-stream.test.js
@@ -8,18 +8,37 @@ import {
} from "node:stream";
describe("Readable", () => {
- it("should be able to be piped via .pipe", () => {
+ it("should be able to be created without _construct method defined", (done) => {
const readable = new Readable({
- _read() {
+ read() {
+ this.push("Hello World!\n");
+ this.push(null);
+ },
+ });
+ expect(readable instanceof Readable).toBe(true);
+ let data = "";
+ readable.on("data", (chunk) => {
+ data += chunk.toString();
+ });
+ readable.on("end", () => {
+ expect(data).toBe("Hello World!\n");
+ done();
+ });
+ });
+
+ it("should be able to be piped via .pipe", (done) => {
+ const readable = new Readable({
+ read() {
this.push("Hello World!");
this.push(null);
},
});
const writable = new Writable({
- _write(chunk, encoding, callback) {
+ write(chunk, encoding, callback) {
expect(chunk.toString()).toBe("Hello World!");
callback();
+ done();
},
});