Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cf875d1

Browse filesBrowse files
edsadrItalo A. Casas
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 <princejohnwesley@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 59196af commit cf875d1
Copy full SHA for cf875d1

File tree

Expand file treeCollapse file tree

1 file changed

+7
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-8
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-fs-null-bytes.js
+7-8Lines changed: 7 additions & 8 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.