Skip to content

Commit

Permalink
test: refactor test-fs-write.js
Browse files Browse the repository at this point in the history
Changed var to const and equal to strictEqual

PR-URL: #9982
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
hirabhullar authored and addaleax committed Dec 8, 2016
1 parent c506b7b commit b893dc9
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions test/parallel/test-fs-write.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
var Buffer = require('buffer').Buffer;
var fs = require('fs');
var fn = path.join(common.tmpDir, 'write.txt');
var fn2 = path.join(common.tmpDir, 'write2.txt');
var expected = 'ümlaut.';
var constants = fs.constants;
const common = require('../common');
const assert = require('assert');
const path = require('path');
const Buffer = require('buffer').Buffer;
const fs = require('fs');
const fn = path.join(common.tmpDir, 'write.txt');
const fn2 = path.join(common.tmpDir, 'write2.txt');
const expected = 'ümlaut.';
const constants = fs.constants;

common.refreshTmpDir();

fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
if (err) throw err;
console.log('open done');
fs.write(fd, '', 0, 'utf8', function(err, written) {
assert.equal(0, written);
assert.strictEqual(0, written);
});
fs.write(fd, expected, 0, 'utf8', common.mustCall(function(err, written) {
console.log('write done');
if (err) throw err;
assert.equal(Buffer.byteLength(expected), written);
assert.strictEqual(Buffer.byteLength(expected), written);
fs.closeSync(fd);
const found = fs.readFileSync(fn, 'utf8');
console.log('expected: "%s"', expected);
Expand All @@ -36,12 +36,12 @@ fs.open(fn2, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644,
if (err) throw err;
console.log('open done');
fs.write(fd, '', 0, 'utf8', (err, written) => {
assert.equal(0, written);
assert.strictEqual(0, written);
});
fs.write(fd, expected, 0, 'utf8', common.mustCall((err, written) => {
console.log('write done');
if (err) throw err;
assert.equal(Buffer.byteLength(expected), written);
assert.strictEqual(Buffer.byteLength(expected), written);
fs.closeSync(fd);
const found = fs.readFileSync(fn2, 'utf8');
console.log('expected: "%s"', expected);
Expand Down

0 comments on commit b893dc9

Please sign in to comment.