Skip to content

Commit

Permalink
test: improve test-fs-null-bytes
Browse files Browse the repository at this point in the history
* 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: nodejs#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>
  • Loading branch information
edsadr authored and italoacasas committed Jan 27, 2017
1 parent 59196af commit cf875d1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions test/parallel/test-fs-null-bytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ var assert = require('assert');
var fs = require('fs');

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

if (sync)
assert.throws(function() {
console.error(sync.name, argsSync);
assert.throws(() => {
sync.apply(null, argsSync);
}, expected);

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

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

0 comments on commit cf875d1

Please sign in to comment.