Skip to content

Commit 4b54520

Browse files
lucamaraschiitaloacasas
authored andcommitted
test: refactor mkdtemp test and added async
This test refactored the original test for mkdtempSync prefix validation and added the test also for the async function mkdtemp. PR-URL: #12080 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent 8caf6fd commit 4b54520

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const fs = require('fs');
5+
6+
const expectedError = /^TypeError: filename prefix is required$/;
7+
const prefixValues = [undefined, null, 0, true, false, 1, ''];
8+
9+
function fail(value) {
10+
assert.throws(
11+
() => fs.mkdtempSync(value, {}),
12+
expectedError
13+
);
14+
}
15+
16+
function failAsync(value) {
17+
assert.throws(
18+
() => fs.mkdtemp(value, common.mustNotCall()), expectedError
19+
);
20+
}
21+
22+
prefixValues.forEach((prefixValue) => {
23+
fail(prefixValue);
24+
failAsync(prefixValue);
25+
});

test/parallel/test-mkdtemp-sync-prefix-check.js

-13
This file was deleted.

0 commit comments

Comments
 (0)