node/test/parallel/test-fs-make-callback.js
Mohammed Keyvanzadeh 8c4b8b201a
lib: replace validator and error
Refs: https://github.com/nodejs/node/pull/41660

PR-URL: https://github.com/nodejs/node/pull/41678
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-02-05 08:36:48 -08:00

29 lines
679 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const fs = require('fs');
const callbackThrowValues = [null, true, false, 0, 1, 'foo', /foo/, [], {}];
const { sep } = require('path');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
function testMakeCallback(cb) {
return function() {
// fs.mkdtemp() calls makeCallback() on its third argument
fs.mkdtemp(`${tmpdir.path}${sep}`, {}, cb);
};
}
function invalidCallbackThrowsTests() {
callbackThrowValues.forEach((value) => {
assert.throws(testMakeCallback(value), {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError'
});
});
}
invalidCallbackThrowsTests();