From c2663e1d82521e9b68a7e2e96197030a4ee00c30 Mon Sep 17 00:00:00 2001 From: Sajjad Hashemian Date: Mon, 10 Sep 2018 14:18:36 +0430 Subject: Implement deno.mkdir() --- js/mkdir_test.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 js/mkdir_test.ts (limited to 'js/mkdir_test.ts') 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()); +}); -- cgit v1.2.3