node/test/parallel/test-fs-mkdtemp-prefix-check.js
Ryan Williams 242cbd7d1a
test: replace forEach with for...of
PR-URL: https://github.com/nodejs/node/pull/50611
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-11-12 11:24:52 +00:00

34 lines
620 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const prefixValues = [undefined, null, 0, true, false, 1];
function fail(value) {
assert.throws(
() => {
fs.mkdtempSync(value, {});
},
{
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError'
});
}
function failAsync(value) {
assert.throws(
() => {
fs.mkdtemp(value, common.mustNotCall());
},
{
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError'
});
}
for (const prefixValue of prefixValues) {
fail(prefixValue);
failAsync(prefixValue);
}