2017-11-26 12:44:20 -08:00
|
|
|
'use strict';
|
|
|
|
|
2017-11-29 12:52:16 +08:00
|
|
|
// This tests that the errors thrown from fs.close and fs.closeSync
|
|
|
|
// include the desired properties
|
|
|
|
|
2018-03-19 13:33:46 +01:00
|
|
|
require('../common');
|
|
|
|
const assert = require('assert');
|
2017-11-26 12:44:20 -08:00
|
|
|
const fs = require('fs');
|
|
|
|
|
2018-03-19 13:33:46 +01:00
|
|
|
['', false, null, undefined, {}, []].forEach((input) => {
|
|
|
|
const errObj = {
|
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
|
|
name: 'TypeError [ERR_INVALID_ARG_TYPE]',
|
2018-03-19 14:17:50 +01:00
|
|
|
message: 'The "fd" argument must be of type number. ' +
|
|
|
|
`Received type ${typeof input}`
|
2018-03-19 13:33:46 +01:00
|
|
|
};
|
|
|
|
assert.throws(() => fs.close(input), errObj);
|
|
|
|
assert.throws(() => fs.closeSync(input), errObj);
|
2017-11-26 12:44:20 -08:00
|
|
|
});
|