diff options
author | 2023-01-10 17:16:16 -0800 | |
---|---|---|
committer | 2023-01-10 17:16:16 -0800 | |
commit | 3517ce8e2368d07b2ab6983fb86974abed675c25 (patch) | |
tree | 4031c2fd14df69407c2b20c1e0fe6e5eb687d473 | |
parent | 3c525b4962030b847ba79c02810b0aedbe3eb29f (diff) | |
download | bun-3517ce8e2368d07b2ab6983fb86974abed675c25.tar.gz bun-3517ce8e2368d07b2ab6983fb86974abed675c25.tar.zst bun-3517ce8e2368d07b2ab6983fb86974abed675c25.zip |
Add two tests for fs/promises
-rw-r--r-- | test/bun.js/fs.test.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/bun.js/fs.test.js b/test/bun.js/fs.test.js index 3d8a7978a..1a5ba24d4 100644 --- a/test/bun.js/fs.test.js +++ b/test/bun.js/fs.test.js @@ -17,6 +17,7 @@ import { rmSync, createReadStream, createWriteStream, + promises, } from "node:fs"; import { join } from "node:path"; @@ -540,3 +541,18 @@ describe("createWriteStream", () => { }); }); }); + +describe("fs/promises", () => { + const { readFile, writeFile } = promises; + + it("readFile", async () => { + const data = await readFile(import.meta.dir + "/readFileSync.txt", "utf8"); + expect(data).toBe("File read successfully"); + }); + + it("writeFile", async () => { + const path = `/tmp/fs.test.js/${Date.now()}.writeFile.txt`; + await writeFile(path, "File written successfully"); + expect(readFileSync(path, "utf8")).toBe("File written successfully"); + }); +}); |