From 0a318ecca14ab1e71aa60ae8eadbd16343b3a3ea Mon Sep 17 00:00:00 2001 From: MrPalixir <73360179+coratgerl@users.noreply.github.com> Date: Sun, 17 Sep 2023 03:51:18 +0200 Subject: fix: node compatibility with empty path string (#4693) Co-authored-by: MrPalixir <73360179+MrPalixir@users.noreply.github.com> --- test/js/node/fs/fs.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/js') diff --git a/test/js/node/fs/fs.test.ts b/test/js/node/fs/fs.test.ts index 41275edd5..3e030f609 100644 --- a/test/js/node/fs/fs.test.ts +++ b/test/js/node/fs/fs.test.ts @@ -953,6 +953,23 @@ describe("stat", () => { } catch (e: any) { expect(e.code).toBe("ENOENT"); } + + try { + statSync(""); + throw "statSync should throw"; + } catch (e: any) { + expect(e.code).toBe("ENOENT"); + } + }); +}); + +describe("exist", () => { + it("should return false with invalid path", () => { + expect(existsSync("/pathNotExist")).toBe(false); + }); + + it("should return false with empty string", () => { + expect(existsSync("")).toBe(false); }); }); -- cgit v1.2.3