diff --git a/test/parallel/test-fs-mkdtemp-prefix-check.js b/test/parallel/test-fs-mkdtemp-prefix-check.js new file mode 100644 index 00000000000000..786d0fe7bae169 --- /dev/null +++ b/test/parallel/test-fs-mkdtemp-prefix-check.js @@ -0,0 +1,25 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); + +const expectedError = /^TypeError: filename prefix is required$/; +const prefixValues = [undefined, null, 0, true, false, 1, '']; + +function fail(value) { + assert.throws( + () => fs.mkdtempSync(value, {}), + expectedError + ); +} + +function failAsync(value) { + assert.throws( + () => fs.mkdtemp(value, common.mustNotCall()), expectedError + ); +} + +prefixValues.forEach((prefixValue) => { + fail(prefixValue); + failAsync(prefixValue); +}); diff --git a/test/parallel/test-mkdtemp-sync-prefix-check.js b/test/parallel/test-mkdtemp-sync-prefix-check.js deleted file mode 100644 index 825f622f069b5e..00000000000000 --- a/test/parallel/test-mkdtemp-sync-prefix-check.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; -require('../common'); -const assert = require('assert'); -const fs = require('fs'); - -const assertValues = [undefined, null, 0, true, false, 1]; - -assertValues.forEach((assertValue) => { - assert.throws( - () => fs.mkdtempSync(assertValue, {}), - /^TypeError: filename prefix is required$/ - ); -});