summaryrefslogtreecommitdiff
path: root/tests/unit_node/_fs/_fs_copy_test.ts
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-04-20 17:11:27 +0530
committerGitHub <noreply@github.com>2024-04-20 11:41:27 +0000
commit04c6785faecdef37b3d4eefb61c0a18ff1cbdec0 (patch)
tree12f4daf9b599cb0de8378673f0a37a14fe4c209d /tests/unit_node/_fs/_fs_copy_test.ts
parente0554ac4a2da95ad98eef36246283cb8f38a3afe (diff)
fix(ext/node): `cp` into non-existent parent directory (#23469)
Fixes https://github.com/denoland/deno/issues/20604
Diffstat (limited to 'tests/unit_node/_fs/_fs_copy_test.ts')
-rw-r--r--tests/unit_node/_fs/_fs_copy_test.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/unit_node/_fs/_fs_copy_test.ts b/tests/unit_node/_fs/_fs_copy_test.ts
index 036091303..adc002187 100644
--- a/tests/unit_node/_fs/_fs_copy_test.ts
+++ b/tests/unit_node/_fs/_fs_copy_test.ts
@@ -2,7 +2,7 @@
import * as path from "@std/path/mod.ts";
import { assert } from "@std/assert/mod.ts";
import { assertCallbackErrorUncaught } from "../_test_utils.ts";
-import { copyFile, copyFileSync, existsSync } from "node:fs";
+import { copyFile, copyFileSync, cpSync, existsSync } from "node:fs";
const destFile = "./destination.txt";
@@ -50,3 +50,13 @@ Deno.test("[std/node/fs] copyFile callback isn't called twice if error is thrown
},
});
});
+
+Deno.test("[std/node/fs] cp creates destination directory", async () => {
+ const tempDir = await Deno.makeTempDir();
+ const tempFile1 = path.join(tempDir, "file1.txt");
+ const tempFile2 = path.join(tempDir, "dir", "file2.txt");
+ await Deno.writeTextFile(tempFile1, "hello world");
+ cpSync(tempFile1, tempFile2);
+ assert(existsSync(tempFile2));
+ await Deno.remove(tempDir, { recursive: true });
+});