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 assert = require('assert');
const fs = require('fs'); 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. // sometimes stat returns size=0, but it's a lie.
fs._fstat = fs.fstat; fs._fstat = fs.fstat;
fs._fstatSync = fs.fstatSync; fs._fstatSync = fs.fstatSync;
fs.fstat = function(fd, cb) { fs.fstat = (fd, cb) => {
fs._fstat(fd, function(er, st) { fs._fstat(fd, (er, st) => {
if (er) return cb(er); if (er) return cb(er);
st.size = 0; st.size = 0;
return cb(er, st); return cb(er, st);
}); });
}; };
fs.fstatSync = function(fd) { fs.fstatSync = (fd) => {
var st = fs._fstatSync(fd); const st = fs._fstatSync(fd);
st.size = 0; st.size = 0;
return st; return st;
}; };
var d = fs.readFileSync(__filename, 'utf8'); const d = fs.readFileSync(__filename, 'utf8');
assert.equal(d, dataExpected); assert.strictEqual(d, dataExpected);
fs.readFile(__filename, 'utf8', common.mustCall(function(er, d) { fs.readFile(__filename, 'utf8', common.mustCall((er, d) => {
assert.equal(d, dataExpected); assert.strictEqual(d, dataExpected);
})); }));

Loading…
Cancel
Save