Skip to content

Commit 36930e4

Browse files
RaisinTentargos
authored andcommitted
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: #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>
1 parent ab64d74 commit 36930e4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/parallel/test-fs-mkdir.js

+19
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,25 @@ function nextdir() {
5353
}));
5454
}
5555

56+
// fs.mkdir creates directory with mode passed as an options object
57+
{
58+
const pathname = path.join(tmpdir.path, nextdir());
59+
60+
fs.mkdir(pathname, { mode: 0o777 }, common.mustCall(function(err) {
61+
assert.strictEqual(err, null);
62+
assert.strictEqual(fs.existsSync(pathname), true);
63+
}));
64+
}
65+
66+
// fs.mkdirSync creates directory with mode passed as an options object
67+
{
68+
const pathname = path.join(tmpdir.path, nextdir());
69+
70+
fs.mkdirSync(pathname, { mode: 0o777 });
71+
72+
assert.strictEqual(fs.existsSync(pathname), true);
73+
}
74+
5675
// mkdirSync successfully creates directory from given path
5776
{
5877
const pathname = path.join(tmpdir.path, nextdir());

0 commit comments

Comments
 (0)