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 targos committed Nov 8, 2019
1 parent ac34840 commit 5e436f8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/parallel/test-fs-close-errors.js
Original file line number Diff line number Diff line change
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 5e436f8

Please sign in to comment.