Skip to content

Commit cf875d1

Browse files
edsadritaloacasas
authored andcommitted
test: improve test-fs-null-bytes
* use const instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions * remove console.error PR-URL: #10521 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 59196af commit cf875d1

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

test/parallel/test-fs-null-bytes.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ var assert = require('assert');
44
var fs = require('fs');
55

66
function check(async, sync) {
7-
var expected = /Path must be a string without null bytes/;
8-
var argsSync = Array.prototype.slice.call(arguments, 2);
9-
var argsAsync = argsSync.concat(function(er) {
7+
const expected = /Path must be a string without null bytes/;
8+
const argsSync = Array.prototype.slice.call(arguments, 2);
9+
const argsAsync = argsSync.concat((er) => {
1010
assert(er && er.message.match(expected));
11-
assert.equal(er.code, 'ENOENT');
11+
assert.strictEqual(er.code, 'ENOENT');
1212
});
1313

1414
if (sync)
15-
assert.throws(function() {
16-
console.error(sync.name, argsSync);
15+
assert.throws(() => {
1716
sync.apply(null, argsSync);
1817
}, expected);
1918

@@ -51,7 +50,7 @@ check(fs.writeFile, fs.writeFileSync, 'foo\u0000bar');
5150

5251
// an 'error' for exists means that it doesn't exist.
5352
// one of many reasons why this file is the absolute worst.
54-
fs.exists('foo\u0000bar', function(exists) {
53+
fs.exists('foo\u0000bar', common.mustCall((exists) => {
5554
assert(!exists);
56-
});
55+
}));
5756
assert(!fs.existsSync('foo\u0000bar'));

0 commit comments

Comments
 (0)