Browse Source

test: improve test-fs-readfile-zero-byte-liar

* use const instead of var
* use assert.strictEqual instead of assert.equal
* use arrow functions

PR-URL: https://github.com/nodejs/node/pull/10570
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6
Adrian Estrada 8 years ago
committed by Luigi Pinca
parent
commit
a5bdcc39ac
  1. 18
      test/parallel/test-fs-readfile-zero-byte-liar.js

18
test/parallel/test-fs-readfile-zero-byte-liar.js

@ -3,29 +3,29 @@ const common = require('../common');
const assert = require('assert');
const 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);
}));

Loading…
Cancel
Save