mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 20:09:04 +00:00
Deflake
This commit is contained in:
19
test/js/node/stream/emit-readable-on-end.js
Normal file
19
test/js/node/stream/emit-readable-on-end.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const { writeFileSync, createReadStream } = require("fs");
|
||||
const { join } = require("path");
|
||||
const { tmpdir } = require("os");
|
||||
|
||||
// This test should fail if ot doesn't go through the "readable" event
|
||||
process.exitCode = 1;
|
||||
|
||||
const testData = new Uint8Array(parseInt(process.env.READABLE_SIZE || (1024 * 1024).toString(10))).fill("a");
|
||||
const path = join(tmpdir(), `${Date.now()}-testEmitReadableOnEnd.txt`);
|
||||
writeFileSync(path, testData);
|
||||
|
||||
const stream = createReadStream(path);
|
||||
|
||||
stream.on("readable", () => {
|
||||
const chunk = stream.read();
|
||||
if (!chunk) {
|
||||
process.exitCode = 0;
|
||||
}
|
||||
});
|
||||
@@ -188,18 +188,8 @@ describe("createReadStream", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("should emit readable on end", done => {
|
||||
const testData = "Hello world";
|
||||
const path = join(tmpdir(), `${Date.now()}-testEmitReadableOnEnd.txt`);
|
||||
writeFileSync(path, testData);
|
||||
const stream = createReadStream(path);
|
||||
|
||||
stream.on("readable", () => {
|
||||
const chunk = stream.read();
|
||||
if (!chunk) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
it("should emit readable on end", () => {
|
||||
expect([join(import.meta.dir, "emit-readable-on-end.js")]).toRun();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user