aboutsummaryrefslogtreecommitdiff
path: root/test/js
diff options
context:
space:
mode:
authorGravatar Ai Hoshino <ambiguous404@gmail.com> 2023-09-27 18:40:45 +0800
committerGravatar GitHub <noreply@github.com> 2023-09-27 03:40:45 -0700
commita0081f9e29e72ae800373b536e03fe1d729c68ae (patch)
tree12b785e83f661d3c93d21db8e9b2204d00395348 /test/js
parent4d2b442a33f2f0538c4655152d1798f40f84d03d (diff)
downloadbun-a0081f9e29e72ae800373b536e03fe1d729c68ae.tar.gz
bun-a0081f9e29e72ae800373b536e03fe1d729c68ae.tar.zst
bun-a0081f9e29e72ae800373b536e03fe1d729c68ae.zip
fix(node:fs): fix `fs.exists` callback parameters (#6097)
Close: #6073
Diffstat (limited to 'test/js')
-rw-r--r--test/js/node/fs/fs.test.ts41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/js/node/fs/fs.test.ts b/test/js/node/fs/fs.test.ts
index 78b6c21f3..791386956 100644
--- a/test/js/node/fs/fs.test.ts
+++ b/test/js/node/fs/fs.test.ts
@@ -1002,6 +1002,47 @@ describe("exist", () => {
});
});
+describe("fs.exists", () => {
+ it("should throw TypeError with invalid argument", done => {
+ let err = undefined;
+ try {
+ // @ts-ignore
+ fs.exists(import.meta.path);
+ } catch (e) {
+ err = e;
+ }
+ try {
+ expect(err).not.toBeUndefined();
+ expect(err).toBeInstanceOf(TypeError);
+ // @ts-ignore
+ expect(err.code).toStrictEqual("ERR_INVALID_ARG_TYPE");
+ done();
+ } catch (e) {
+ done(e);
+ }
+ });
+ it("should return false with invalid path", done => {
+ fs.exists(`${tmpdir()}/test-fs-exists-${Date.now()}`, exists => {
+ try {
+ expect(exists).toBe(false);
+ done();
+ } catch (e) {
+ done(e);
+ }
+ });
+ });
+ it("should return true with existed path", done => {
+ fs.exists(import.meta.path, exists => {
+ try {
+ expect(exists).toBe(true);
+ done();
+ } catch (e) {
+ done(e);
+ }
+ });
+ });
+});
+
describe("rm", () => {
it("removes a file", () => {
const path = `${tmpdir()}/${Date.now()}.rm.txt`;