From 36930e4fe75f05b5ba69373df552de160664d584 Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Wed, 20 Jan 2021 19:58:42 +0530 Subject: [PATCH] test: test mode passed as an options object in mkdir/mkdirSync Add tests for mode passed as an options object in fs.mkdir() and fs.mkdirSync(). This also adds coverage for mkdirSync() inside the conditional where options.mode is not undefined. PR-URL: https://github.com/nodejs/node/pull/37008 Refs: https://coverage.nodejs.org/coverage-e3e054d020ee5ef6/lib/fs.js.html#L1023 Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott --- test/parallel/test-fs-mkdir.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/parallel/test-fs-mkdir.js b/test/parallel/test-fs-mkdir.js index 5e28d6b944b6e0..4124a638a20234 100644 --- a/test/parallel/test-fs-mkdir.js +++ b/test/parallel/test-fs-mkdir.js @@ -53,6 +53,25 @@ function nextdir() { })); } +// fs.mkdir creates directory with mode passed as an options object +{ + const pathname = path.join(tmpdir.path, nextdir()); + + fs.mkdir(pathname, { mode: 0o777 }, common.mustCall(function(err) { + assert.strictEqual(err, null); + assert.strictEqual(fs.existsSync(pathname), true); + })); +} + +// fs.mkdirSync creates directory with mode passed as an options object +{ + const pathname = path.join(tmpdir.path, nextdir()); + + fs.mkdirSync(pathname, { mode: 0o777 }); + + assert.strictEqual(fs.existsSync(pathname), true); +} + // mkdirSync successfully creates directory from given path { const pathname = path.join(tmpdir.path, nextdir());