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 <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Darshan Sen authored and Rich Trott committed 2021-01-23 11:05:26 -08:00
1 parent dbdc14b0e8
commit 3f4bfef607
1 file changed
+19
+19
View File
@@ -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());