Browse Source

test: modernize test-fs-truncate-fd

- changed `var` to `const` where variables were not reassigned.
- changed `assert.equal` to `assert.strictEqual` because there was no
downside to being more rigorous.

PR-URL: https://github.com/nodejs/node/pull/9978
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6
Nigel Kibodeaux 8 years ago
committed by James M Snell
parent
commit
c9945672fc
  1. 16
      test/parallel/test-fs-truncate-fd.js

16
test/parallel/test-fs-truncate-fd.js

@ -1,17 +1,17 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
var path = require('path'); const path = require('path');
var fs = require('fs'); const fs = require('fs');
var tmp = common.tmpDir; const tmp = common.tmpDir;
common.refreshTmpDir(); common.refreshTmpDir();
var filename = path.resolve(tmp, 'truncate-file.txt'); const filename = path.resolve(tmp, 'truncate-file.txt');
fs.writeFileSync(filename, 'hello world', 'utf8'); fs.writeFileSync(filename, 'hello world', 'utf8');
var fd = fs.openSync(filename, 'r+'); const fd = fs.openSync(filename, 'r+');
fs.truncate(fd, 5, common.mustCall(function(err) { fs.truncate(fd, 5, common.mustCall(function(err) {
assert.ok(!err); assert.ok(!err);
assert.equal(fs.readFileSync(filename, 'utf8'), 'hello'); assert.strictEqual(fs.readFileSync(filename, 'utf8'), 'hello');
})); }));
process.on('exit', function() { process.on('exit', function() {

Loading…
Cancel
Save