mirror of
https://github.com/nodejs/node.git
synced 2024-11-29 23:16:30 +01:00
acc3c770e7
Right now there are multiple cases where the validated entry would not be returned or a wrong error is thrown. This fixes both cases. PR-URL: https://github.com/nodejs/node/pull/19445 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
20 lines
572 B
JavaScript
20 lines
572 B
JavaScript
'use strict';
|
|
|
|
// This tests that the errors thrown from fs.close and fs.closeSync
|
|
// include the desired properties
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
|
|
['', false, null, undefined, {}, []].forEach((input) => {
|
|
const errObj = {
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError [ERR_INVALID_ARG_TYPE]',
|
|
message: 'The "fd" argument must be of type number. ' +
|
|
`Received type ${typeof input}`
|
|
};
|
|
assert.throws(() => fs.close(input), errObj);
|
|
assert.throws(() => fs.closeSync(input), errObj);
|
|
});
|