Skip to content
Permalink
Browse files

test: add cb error test for fs.close()

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 Oct 14, 2019
1 parent b57fe3b commit 3e399090225302ed0cdaf136c24fdb5e41677479
Showing with 16 additions and 0 deletions.
  1. +16 −0 test/parallel/test-fs-close-errors.js
@@ -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 3e39909

Please sign in to comment.
You can’t perform that action at this time.