Skip to content

Commit 727c5e3

Browse files
edsadritaloacasas
authored andcommitted
test: improve test-fs-write-file-sync
* use let and const instead of var * use assert.strictEqual instead of assert.equal * swap assertions arguments to match the standard PR-URL: #10624 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 6e0888a commit 727c5e3

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

test/parallel/test-fs-write-file-sync.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ const common = require('../common');
33
const assert = require('assert');
44
const path = require('path');
55
const fs = require('fs');
6-
var openCount = 0;
7-
var mode;
8-
var content;
6+
let openCount = 0;
7+
let mode;
8+
let content;
99

1010
// Need to hijack fs.open/close to make sure that things
1111
// get closed once they're opened.
@@ -28,39 +28,39 @@ if (common.isWindows) {
2828
common.refreshTmpDir();
2929

3030
// Test writeFileSync
31-
var file1 = path.join(common.tmpDir, 'testWriteFileSync.txt');
31+
const file1 = path.join(common.tmpDir, 'testWriteFileSync.txt');
3232

3333
fs.writeFileSync(file1, '123', {mode: mode});
3434

3535
content = fs.readFileSync(file1, {encoding: 'utf8'});
36-
assert.equal('123', content);
36+
assert.strictEqual(content, '123');
3737

38-
assert.equal(mode, fs.statSync(file1).mode & 0o777);
38+
assert.strictEqual(fs.statSync(file1).mode & 0o777, mode);
3939

4040
// Test appendFileSync
41-
var file2 = path.join(common.tmpDir, 'testAppendFileSync.txt');
41+
const file2 = path.join(common.tmpDir, 'testAppendFileSync.txt');
4242

4343
fs.appendFileSync(file2, 'abc', {mode: mode});
4444

4545
content = fs.readFileSync(file2, {encoding: 'utf8'});
46-
assert.equal('abc', content);
46+
assert.strictEqual(content, 'abc');
4747

48-
assert.equal(mode, fs.statSync(file2).mode & mode);
48+
assert.strictEqual(fs.statSync(file2).mode & mode, mode);
4949

5050
// Test writeFileSync with file descriptor
51-
var file3 = path.join(common.tmpDir, 'testWriteFileSyncFd.txt');
51+
const file3 = path.join(common.tmpDir, 'testWriteFileSyncFd.txt');
5252

53-
var fd = fs.openSync(file3, 'w+', mode);
53+
const fd = fs.openSync(file3, 'w+', mode);
5454
fs.writeFileSync(fd, '123');
5555
fs.closeSync(fd);
5656

5757
content = fs.readFileSync(file3, {encoding: 'utf8'});
58-
assert.equal('123', content);
58+
assert.strictEqual(content, '123');
5959

60-
assert.equal(mode, fs.statSync(file3).mode & 0o777);
60+
assert.strictEqual(fs.statSync(file3).mode & 0o777, mode);
6161

6262
// Verify that all opened files were closed.
63-
assert.equal(0, openCount);
63+
assert.strictEqual(openCount, 0);
6464

6565
function openSync() {
6666
openCount++;

0 commit comments

Comments
 (0)