Skip to content

Commit

Permalink
test: refactor mkdtemp test and added async
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
lucamaraschi authored and jasnell committed Apr 4, 2017
1 parent f4e8a6f commit 085c1f8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
25 changes: 25 additions & 0 deletions test/parallel/test-fs-mkdtemp-prefix-check.js
Original file line number Diff line number Diff line change
@@ -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);
});
13 changes: 0 additions & 13 deletions test/parallel/test-mkdtemp-sync-prefix-check.js

This file was deleted.

0 comments on commit 085c1f8

Please sign in to comment.