bug fix and tests for std/node/fs/mkdir (#4917)

This commit is contained in:
Ali Hasani 2020-04-27 17:18:54 +04:30 committed by GitHub
parent fe5b151755
commit 516d970fd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 1 deletions

View file

@ -20,7 +20,7 @@ export function mkdir(
let recursive = false; let recursive = false;
if (typeof options == "function") { if (typeof options == "function") {
callback == options; callback = options;
} else if (typeof options === "number") { } else if (typeof options === "number") {
mode = options; mode = options;
} else if (typeof options === "boolean") { } else if (typeof options === "boolean") {

View file

@ -0,0 +1,32 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { assert } from "../../testing/asserts.ts";
import { mkdir, mkdirSync } from "./_fs_mkdir.ts";
import { existsSync } from "./_fs_exists.ts";
const { test } = Deno;
const tmpDir = "./tmpdir";
test({
name: "[node/fs] mkdir",
fn: async () => {
const result = await new Promise((resolve) => {
mkdir(tmpDir, (err) => {
err && resolve(false);
resolve(existsSync(tmpDir));
Deno.removeSync(tmpDir);
});
});
assert(result);
},
});
test({
name: "[node/fs] mkdirSync",
fn: () => {
mkdirSync(tmpDir);
assert(existsSync(tmpDir));
Deno.removeSync(tmpDir);
},
});