Skip to content

Commit

Permalink
test: add cb error test for fs.close()
Browse files Browse the repository at this point in the history
Provides some missing test coverage.

PR-URL: #29970
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
teorossi82 authored and MylesBorins committed Oct 23, 2019
1 parent dc83ff9 commit b1b8663
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/parallel/test-fs-close-errors.js
Expand Up @@ -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);
}

0 comments on commit b1b8663

Please sign in to comment.