Skip to content

Commit 1e3b3e7

Browse files
committed
test: improve the code in 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
1 parent e407478 commit 1e3b3e7

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var fs = require('fs');
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const 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)