1'use strict'; 2 3// This tests that the errors thrown from fs.close and fs.closeSync 4// include the desired properties 5 6const common = require('../common'); 7const assert = require('assert'); 8const fs = require('fs'); 9 10['', false, null, undefined, {}, []].forEach((input) => { 11 const errObj = { 12 code: 'ERR_INVALID_ARG_TYPE', 13 name: 'TypeError', 14 message: 'The "fd" argument must be of type number.' + 15 common.invalidArgTypeHelper(input) 16 }; 17 assert.throws(() => fs.close(input), errObj); 18 assert.throws(() => fs.closeSync(input), errObj); 19}); 20 21{ 22 // Test error when cb is not a function 23 const fd = fs.openSync(__filename, 'r'); 24 25 const errObj = { 26 code: 'ERR_INVALID_CALLBACK', 27 name: 'TypeError' 28 }; 29 30 ['', false, null, {}, []].forEach((input) => { 31 assert.throws(() => fs.close(fd, input), errObj); 32 }); 33 34 fs.closeSync(fd); 35} 36