mirror of
https://github.com/denoland/deno.git
synced 2025-10-02 07:01:16 +00:00
parent
02c3c97ddd
commit
2db683e47e
8 changed files with 80 additions and 5 deletions
30
mkdirp/test.ts
Normal file
30
mkdirp/test.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { cwd, lstat, makeTempDirSync, removeAll, FileInfo } from "deno";
|
||||
import { test, assert } from "https://deno.land/x/testing/testing.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);
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue