test: add cb error test for fs.close()
Provides some missing test coverage. PR-URL: https://github.com/nodejs/node/pull/29970 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
46648eb55d
commit
e22efba812
@ -17,3 +17,19 @@ const fs = require('fs');
|
||||
assert.throws(() => fs.close(input), errObj);
|
||||
assert.throws(() => fs.closeSync(input), errObj);
|
||||
});
|
||||
|
||||
{
|
||||
// Test error when cb is not a function
|
||||
const fd = fs.openSync(__filename, 'r');
|
||||
|
||||
const errObj = {
|
||||
code: 'ERR_INVALID_CALLBACK',
|
||||
name: 'TypeError'
|
||||
};
|
||||
|
||||
['', false, null, {}, []].forEach((input) => {
|
||||
assert.throws(() => fs.close(fd, input), errObj);
|
||||
});
|
||||
|
||||
fs.closeSync(fd);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user