Skip to content

Commit

Permalink
test: improve test-fs-readfile-zero-byte-liar
Browse files Browse the repository at this point in the history
* use const instead of var
* use assert.strictEqual instead of assert.equal
* use arrow functions

PR-URL: #10570
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
edsadr authored and MylesBorins committed Mar 9, 2017
1 parent 3f3c78d commit 1ae95e6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/parallel/test-fs-readfile-zero-byte-liar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ const common = require('../common');
var assert = require('assert');
var fs = require('fs');

var dataExpected = fs.readFileSync(__filename, 'utf8');
const dataExpected = fs.readFileSync(__filename, 'utf8');

// sometimes stat returns size=0, but it's a lie.
fs._fstat = fs.fstat;
fs._fstatSync = fs.fstatSync;

fs.fstat = function(fd, cb) {
fs._fstat(fd, function(er, st) {
fs.fstat = (fd, cb) => {
fs._fstat(fd, (er, st) => {
if (er) return cb(er);
st.size = 0;
return cb(er, st);
});
};

fs.fstatSync = function(fd) {
var st = fs._fstatSync(fd);
fs.fstatSync = (fd) => {
const st = fs._fstatSync(fd);
st.size = 0;
return st;
};

var d = fs.readFileSync(__filename, 'utf8');
assert.equal(d, dataExpected);
const d = fs.readFileSync(__filename, 'utf8');
assert.strictEqual(d, dataExpected);

fs.readFile(__filename, 'utf8', common.mustCall(function(er, d) {
assert.equal(d, dataExpected);
fs.readFile(__filename, 'utf8', common.mustCall((er, d) => {
assert.strictEqual(d, dataExpected);
}));

0 comments on commit 1ae95e6

Please sign in to comment.