diff options
Diffstat (limited to 'integration/bunjs-only-snippets/fs.test.js')
-rw-r--r-- | integration/bunjs-only-snippets/fs.test.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/integration/bunjs-only-snippets/fs.test.js b/integration/bunjs-only-snippets/fs.test.js new file mode 100644 index 000000000..4fc5c9e91 --- /dev/null +++ b/integration/bunjs-only-snippets/fs.test.js @@ -0,0 +1,35 @@ +import { describe, it, expect } from "bun:test"; +import { + mkdirSync, + existsSync, + readFileSync, + mkdtempSync, + writeFileSync, +} from "node:fs"; + +const tmp = mkdtempSync("fs-test"); + +describe("mkdirSync", () => { + it("should create a directory", () => { + const tempdir = `${tmp}/1234/hi`; + expect(existsSync(tempdir)).toBe(false); + expect(tempdir.includes(mkdirSync(tempdir, { recursive: true }))).toBe( + true + ); + expect(existsSync(tempdir)).toBe(true); + }); +}); + +describe("readFileSync", () => { + it("works", () => { + const text = readFileSync(import.meta.dir + "/readFileSync.txt", "utf8"); + expect(text).toBe("File read successfully"); + }); +}); + +describe("writeFileSync", () => { + it("works", () => { + const text = writeFileSync(`${tmp}/writeFileSync.txt`, "utf8"); + expect(text).toBe("File read successfully"); + }); +}); |