summaryrefslogtreecommitdiff
path: root/fs/mkdirp_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'fs/mkdirp_test.ts')
-rw-r--r--fs/mkdirp_test.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/fs/mkdirp_test.ts b/fs/mkdirp_test.ts
new file mode 100644
index 000000000..a3a4fac03
--- /dev/null
+++ b/fs/mkdirp_test.ts
@@ -0,0 +1,30 @@
+import { cwd, lstat, makeTempDirSync, removeAll, FileInfo } from "deno";
+import { test, assert } from "../testing/mod.ts";
+import { mkdirp } from "./mkdirp.ts";
+
+let root: string = `${cwd()}/${Date.now()}`; //makeTempDirSync();
+
+test(async function createsNestedDirs(): Promise<void> {
+ const leaf: string = `${root}/levelx/levely`;
+ await mkdirp(leaf);
+ const info: FileInfo = await lstat(leaf);
+ assert(info.isDirectory());
+ await removeAll(root);
+});
+
+test(async function handlesAnyPathSeparator(): Promise<void> {
+ const leaf: string = `${root}\\levelx\\levely`;
+ await mkdirp(leaf);
+ const info: FileInfo = await lstat(leaf.replace(/\\/g, "/"));
+ assert(info.isDirectory());
+ await removeAll(root);
+});
+
+test(async function failsNonDir(): Promise<void> {
+ try {
+ await mkdirp("./test.ts/fest.fs");
+ } catch (err) {
+ // TODO: assert caught DenoError of kind NOT_A_DIRECTORY or similar
+ assert(err);
+ }
+});