mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
There is actually no reason to use `assert.doesNotThrow()` in the tests. If a test throws, just let the error bubble up right away instead of first catching it and then rethrowing it. Backport-PR-URL: https://github.com/nodejs/node/pull/19244 PR-URL: https://github.com/nodejs/node/pull/18669 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
|
|
const tmpFolder = fs.mkdtempSync(path.join(tmpdir.path, 'foo.'));
|
|
|
|
assert.strictEqual(path.basename(tmpFolder).length, 'foo.XXXXXX'.length);
|
|
assert(common.fileExists(tmpFolder));
|
|
|
|
const utf8 = fs.mkdtempSync(path.join(tmpdir.path, '\u0222abc.'));
|
|
assert.strictEqual(Buffer.byteLength(path.basename(utf8)),
|
|
Buffer.byteLength('\u0222abc.XXXXXX'));
|
|
assert(common.fileExists(utf8));
|
|
|
|
function handler(err, folder) {
|
|
assert.ifError(err);
|
|
assert(common.fileExists(folder));
|
|
assert.strictEqual(this, undefined);
|
|
}
|
|
|
|
fs.mkdtemp(path.join(tmpdir.path, 'bar.'), common.mustCall(handler));
|
|
|
|
// Same test as above, but making sure that passing an options object doesn't
|
|
// affect the way the callback function is handled.
|
|
fs.mkdtemp(path.join(tmpdir.path, 'bar.'), {}, common.mustCall(handler));
|
|
|
|
// Making sure that not passing a callback doesn't crash, as a default function
|
|
// is passed internally.
|
|
fs.mkdtemp(path.join(tmpdir.path, 'bar-'));
|
|
fs.mkdtemp(path.join(tmpdir.path, 'bar-'), {});
|