diff options
author | Sajjad Hashemian <wolaws@gmail.com> | 2018-09-10 14:18:36 +0430 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-09-10 15:02:07 -0400 |
commit | c2663e1d82521e9b68a7e2e96197030a4ee00c30 (patch) | |
tree | 5223730175f88d24a028b7d1497a6a7312b77683 /js/mkdir_test.ts | |
parent | e293c204a07f5a7a862e835f8a5f54f5435f8b91 (diff) |
Implement deno.mkdir()
Diffstat (limited to 'js/mkdir_test.ts')
-rw-r--r-- | js/mkdir_test.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/js/mkdir_test.ts b/js/mkdir_test.ts new file mode 100644 index 000000000..ed275bd36 --- /dev/null +++ b/js/mkdir_test.ts @@ -0,0 +1,28 @@ +// Copyright 2018 the Deno authors. All rights reserved. MIT license. +import { test, testPerm, assert, assertEqual } from "./test_util.ts"; +import * as deno from "deno"; + +testPerm({ write: true }, function mkdirSyncSuccess() { + const path = deno.makeTempDirSync() + "/dir/subdir"; + deno.mkdirSync(path); + const pathInfo = deno.statSync(path); + assert(pathInfo.isDirectory()); +}); + +testPerm({ write: false }, function mkdirSyncPerm() { + let err; + try { + deno.mkdirSync("/baddir"); + } catch (e) { + err = e; + } + assertEqual(err.kind, deno.ErrorKind.PermissionDenied); + assertEqual(err.name, "PermissionDenied"); +}); + +testPerm({ write: true }, async function mkdirSuccess() { + const path = deno.makeTempDirSync() + "/dir/subdir"; + await deno.mkdir(path); + const pathInfo = deno.statSync(path); + assert(pathInfo.isDirectory()); +}); |