test: increase coverage for readfile with withFileTypes

According to the test coverage report a test case was missings checking
if an error is passed into the callback for readdir calls with
withFileTypes option.

PR-URL: https://github.com/nodejs/node/pull/23557
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
christian-bromann 2018-10-12 10:43:58 -07:00 committed by Anna Henningsen
parent eff869fecc
commit 6c5e97f2f0
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -49,6 +49,19 @@ function assertDirents(dirents) {
// Check the readdir Sync version
assertDirents(fs.readdirSync(readdirDir, { withFileTypes: true }));
fs.readdir(__filename, {
withFileTypes: true
}, common.mustCall((err) => {
assert.throws(
() => { throw err; },
{
code: 'ENOTDIR',
name: 'Error',
message: `ENOTDIR: not a directory, scandir '${__filename}'`
}
);
}));
// Check the readdir async version
fs.readdir(readdirDir, {
withFileTypes: true