diff options
author | Adrian Estrada <edsadr@gmail.com> | 2017-01-07 09:58:28 -0500 |
---|---|---|
committer | Luigi Pinca <luigipinca@gmail.com> | 2017-01-07 18:44:53 +0100 |
commit | 8a12368a2090440bfd798abf68e5009445a8dced (patch) | |
tree | 77e5bb1d5dbb6ec4a219142c45b55c50fc82d531 /test/parallel/test-fs-write-file-sync.js | |
parent | f895715755b11a6ba1192f0f7c566b9f4caeab49 (diff) | |
download | android-node-v8-8a12368a2090440bfd798abf68e5009445a8dced.tar.gz android-node-v8-8a12368a2090440bfd798abf68e5009445a8dced.tar.bz2 android-node-v8-8a12368a2090440bfd798abf68e5009445a8dced.zip |
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: https://github.com/nodejs/node/pull/10624
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'test/parallel/test-fs-write-file-sync.js')
-rw-r--r-- | test/parallel/test-fs-write-file-sync.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/test/parallel/test-fs-write-file-sync.js b/test/parallel/test-fs-write-file-sync.js index ece5ba48df..ca6324ac1f 100644 --- a/test/parallel/test-fs-write-file-sync.js +++ b/test/parallel/test-fs-write-file-sync.js @@ -3,9 +3,9 @@ const common = require('../common'); const assert = require('assert'); const path = require('path'); const fs = require('fs'); -var openCount = 0; -var mode; -var content; +let openCount = 0; +let mode; +let content; // Need to hijack fs.open/close to make sure that things // get closed once they're opened. @@ -28,39 +28,39 @@ if (common.isWindows) { common.refreshTmpDir(); // Test writeFileSync -var file1 = path.join(common.tmpDir, 'testWriteFileSync.txt'); +const file1 = path.join(common.tmpDir, 'testWriteFileSync.txt'); fs.writeFileSync(file1, '123', {mode: mode}); content = fs.readFileSync(file1, {encoding: 'utf8'}); -assert.equal('123', content); +assert.strictEqual(content, '123'); -assert.equal(mode, fs.statSync(file1).mode & 0o777); +assert.strictEqual(fs.statSync(file1).mode & 0o777, mode); // Test appendFileSync -var file2 = path.join(common.tmpDir, 'testAppendFileSync.txt'); +const file2 = path.join(common.tmpDir, 'testAppendFileSync.txt'); fs.appendFileSync(file2, 'abc', {mode: mode}); content = fs.readFileSync(file2, {encoding: 'utf8'}); -assert.equal('abc', content); +assert.strictEqual(content, 'abc'); -assert.equal(mode, fs.statSync(file2).mode & mode); +assert.strictEqual(fs.statSync(file2).mode & mode, mode); // Test writeFileSync with file descriptor -var file3 = path.join(common.tmpDir, 'testWriteFileSyncFd.txt'); +const file3 = path.join(common.tmpDir, 'testWriteFileSyncFd.txt'); -var fd = fs.openSync(file3, 'w+', mode); +const fd = fs.openSync(file3, 'w+', mode); fs.writeFileSync(fd, '123'); fs.closeSync(fd); content = fs.readFileSync(file3, {encoding: 'utf8'}); -assert.equal('123', content); +assert.strictEqual(content, '123'); -assert.equal(mode, fs.statSync(file3).mode & 0o777); +assert.strictEqual(fs.statSync(file3).mode & 0o777, mode); // Verify that all opened files were closed. -assert.equal(0, openCount); +assert.strictEqual(openCount, 0); function openSync() { openCount++; |