node/test/parallel/test-fs-close-errors.js
Joyee Cheung 5055c29e82
test: use runWithInvalidFD() in tests expecting EBADF
PR-URL: https://github.com/nodejs/node/pull/18864
Fixes: https://github.com/nodejs/node/issues/18820
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-02-22 22:08:52 +08:00

27 lines
606 B
JavaScript

'use strict';
// This tests that the errors thrown from fs.close and fs.closeSync
// include the desired properties
const common = require('../common');
const fs = require('fs');
['', false, null, undefined, {}, []].forEach((i) => {
common.expectsError(
() => fs.close(i),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "fd" argument must be of type integer'
}
);
common.expectsError(
() => fs.closeSync(i),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "fd" argument must be of type integer'
}
);
});