mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
8c4b8b201a
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>
29 lines
679 B
JavaScript
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();
|