Skip to content

Commit 3e39909

Browse files
teorossi82targos
authored andcommitted
test: add cb error test for fs.close()
Provides some missing test coverage. PR-URL: #29970 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent b57fe3b commit 3e39909

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/parallel/test-fs-close-errors.js

+16
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,19 @@ const fs = require('fs');
1717
assert.throws(() => fs.close(input), errObj);
1818
assert.throws(() => fs.closeSync(input), errObj);
1919
});
20+
21+
{
22+
// Test error when cb is not a function
23+
const fd = fs.openSync(__filename, 'r');
24+
25+
const errObj = {
26+
code: 'ERR_INVALID_CALLBACK',
27+
name: 'TypeError'
28+
};
29+
30+
['', false, null, {}, []].forEach((input) => {
31+
assert.throws(() => fs.close(fd, input), errObj);
32+
});
33+
34+
fs.closeSync(fd);
35+
}

0 commit comments

Comments
 (0)