aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js
diff options
context:
space:
mode:
authorGravatar Alex Lam S.L <alexlamsl@gmail.com> 2023-01-15 02:50:55 +0200
committerGravatar GitHub <noreply@github.com> 2023-01-14 16:50:55 -0800
commit136014b13a0df0641cd7d8ff29d8cf41fae92622 (patch)
tree731efa451049fe7304cf96becda2953e19cca903 /test/bun.js
parentd01ec47529fb7d035b9d369c1e524abf220c8242 (diff)
downloadbun-136014b13a0df0641cd7d8ff29d8cf41fae92622.tar.gz
bun-136014b13a0df0641cd7d8ff29d8cf41fae92622.tar.zst
bun-136014b13a0df0641cd7d8ff29d8cf41fae92622.zip
fix bugs (#1795)
- segfault reading stacktrace from `fs/promises` rejections - `Promise` rejection within `describe()` ends testing abruptly - `FSSink.write()` incorrectly handles `objectMode` - `FSSink.write()` throws wrong error codes
Diffstat (limited to '')
-rw-r--r--test/bun.js/fs.test.js26
1 files changed, 16 insertions, 10 deletions
diff --git a/test/bun.js/fs.test.js b/test/bun.js/fs.test.js
index 1a5ba24d4..ac2357143 100644
--- a/test/bun.js/fs.test.js
+++ b/test/bun.js/fs.test.js
@@ -500,20 +500,20 @@ describe("createWriteStream", () => {
const stream = createWriteStream(path);
try {
stream.write(null);
- throw new Error("should not get here");
+ expect(() => {}).toThrow(Error);
} catch (exception) {
expect(exception.code).toBe("ERR_STREAM_NULL_VALUES");
}
});
- it("writing null with objectMode: true throws ERR_STREAM_NULL_VALUES", async () => {
+ it("writing null throws ERR_STREAM_NULL_VALUES (objectMode: true)", async () => {
const path = `/tmp/fs.test.js/${Date.now()}.createWriteStreamNulls.txt`;
const stream = createWriteStream(path, {
objectMode: true,
});
try {
stream.write(null);
- throw new Error("should not get here");
+ expect(() => {}).toThrow(Error);
} catch (exception) {
expect(exception.code).toBe("ERR_STREAM_NULL_VALUES");
}
@@ -524,26 +524,32 @@ describe("createWriteStream", () => {
const stream = createWriteStream(path);
try {
stream.write(false);
- throw new Error("should not get here");
+ expect(() => {}).toThrow(Error);
} catch (exception) {
expect(exception.code).toBe("ERR_INVALID_ARG_TYPE");
}
});
- it("writing false with objectMode: true should not throw", async () => {
+ it("writing false throws ERR_INVALID_ARG_TYPE (objectMode: true)", async () => {
const path = `/tmp/fs.test.js/${Date.now()}.createWriteStreamFalse.txt`;
const stream = createWriteStream(path, {
objectMode: true,
});
- stream.write(false);
- stream.on("error", () => {
- throw new Error("should not get here");
- });
+ try {
+ stream.write(false);
+ expect(() => {}).toThrow(Error);
+ } catch (exception) {
+ expect(exception.code).toBe("ERR_INVALID_ARG_TYPE");
+ }
});
});
describe("fs/promises", () => {
- const { readFile, writeFile } = promises;
+ const { readFile, stat, writeFile } = promises;
+
+ it("should not segfault on exception", async () => {
+ stat("foo/bar");
+ });
it("readFile", async () => {
const data = await readFile(import.meta.dir + "/readFileSync.txt", "utf8");