aboutsummaryrefslogtreecommitdiff
path: root/test/js/node
diff options
context:
space:
mode:
Diffstat (limited to 'test/js/node')
-rw-r--r--test/js/node/fs/fs.test.ts31
1 files changed, 30 insertions, 1 deletions
diff --git a/test/js/node/fs/fs.test.ts b/test/js/node/fs/fs.test.ts
index 3e030f609..f9ef38fe8 100644
--- a/test/js/node/fs/fs.test.ts
+++ b/test/js/node/fs/fs.test.ts
@@ -136,6 +136,35 @@ describe("copyFileSync", () => {
expect(Bun.hash(readFileSync(tempdir + "/copyFileSync.dest.blob"))).toBe(Bun.hash(buffer.buffer));
});
+ it("constants are right", () => {
+ expect(fs.constants.COPYFILE_EXCL).toBe(1);
+ expect(fs.constants.COPYFILE_FICLONE).toBe(2);
+ expect(fs.constants.COPYFILE_FICLONE_FORCE).toBe(4);
+ });
+
+ it("FICLONE option does not error ever", () => {
+ const tempdir = `${tmpdir()}/fs.test.js/${Date.now()}.FICLONE/1234/hi`;
+ expect(existsSync(tempdir)).toBe(false);
+ expect(tempdir.includes(mkdirSync(tempdir, { recursive: true })!)).toBe(true);
+
+ // that don't exist
+ copyFileSync(import.meta.path, tempdir + "/copyFileSync.js", fs.constants.COPYFILE_FICLONE);
+ copyFileSync(import.meta.path, tempdir + "/copyFileSync.js", fs.constants.COPYFILE_FICLONE);
+ copyFileSync(import.meta.path, tempdir + "/copyFileSync.js", fs.constants.COPYFILE_FICLONE);
+ });
+
+ it("COPYFILE_EXCL works", () => {
+ const tempdir = `${tmpdir()}/fs.test.js/${Date.now()}.COPYFILE_EXCL/1234/hi`;
+ expect(existsSync(tempdir)).toBe(false);
+ expect(tempdir.includes(mkdirSync(tempdir, { recursive: true })!)).toBe(true);
+
+ // that don't exist
+ copyFileSync(import.meta.path, tempdir + "/copyFileSync.js", fs.constants.COPYFILE_EXCL);
+ expect(() => {
+ copyFileSync(import.meta.path, tempdir + "/copyFileSync.js", fs.constants.COPYFILE_EXCL);
+ }).toThrow();
+ });
+
if (process.platform === "linux") {
describe("should work when copyFileRange is not available", () => {
it("on large files", () => {
@@ -212,7 +241,7 @@ describe("copyFileSync", () => {
describe("mkdirSync", () => {
it("should create a directory", () => {
- const tempdir = `${tmpdir()}/fs.test.js/${Date.now()}/1234/hi`;
+ const tempdir = `${tmpdir()}/fs.test.js/${Date.now()}.mkdirSync/1234/hi`;
expect(existsSync(tempdir)).toBe(false);
expect(tempdir.includes(mkdirSync(tempdir, { recursive: true })!)).toBe(true);
expect(existsSync(tempdir)).toBe(true);