diff options
author | Richard Karmazin <richard.karmazin@solarwinds.com> | 2016-12-01 11:19:28 -0600 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-12-05 15:35:09 -0800 |
commit | 18cf668d405b0d226408e8397b76881b23e7d93e (patch) | |
tree | 34462c7d6c0995cf6948e33fed4a50416a84f8b4 /test/parallel/test-file-write-stream3.js | |
parent | ef74e03b2a2c0e7c6016e18a91377530ca2efede (diff) | |
download | android-node-v8-18cf668d405b0d226408e8397b76881b23e7d93e.tar.gz android-node-v8-18cf668d405b0d226408e8397b76881b23e7d93e.tar.bz2 android-node-v8-18cf668d405b0d226408e8397b76881b23e7d93e.zip |
test: test-file-write-stream3.js refactor
PR-URL: https://github.com/nodejs/node/pull/10035
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'test/parallel/test-file-write-stream3.js')
-rw-r--r-- | test/parallel/test-file-write-stream3.js | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/test/parallel/test-file-write-stream3.js b/test/parallel/test-file-write-stream3.js index 1243460f9f..961f51ba82 100644 --- a/test/parallel/test-file-write-stream3.js +++ b/test/parallel/test-file-write-stream3.js @@ -9,7 +9,7 @@ const filepath = path.join(common.tmpDir, 'write_pos.txt'); const cb_expected = 'write open close write open close write open close '; -var cb_occurred = ''; +let cb_occurred = ''; const fileDataInitial = 'abcdefghijklmnopqrstuvwxyz'; @@ -34,10 +34,8 @@ common.refreshTmpDir(); function run_test_1() { - var file, buffer, options; - - options = {}; - file = fs.createWriteStream(filepath, options); + const options = {}; + const file = fs.createWriteStream(filepath, options); console.log(' (debug: start ', file.start); console.log(' (debug: pos ', file.pos); @@ -51,10 +49,10 @@ function run_test_1() { console.log(' (debug: start ', file.start); console.log(' (debug: pos ', file.pos); assert.strictEqual(file.bytesWritten, buffer.length); - var fileData = fs.readFileSync(filepath, 'utf8'); + const fileData = fs.readFileSync(filepath, 'utf8'); console.log(' (debug: file data ', fileData); console.log(' (debug: expected ', fileDataExpected_1); - assert.equal(fileData, fileDataExpected_1); + assert.strictEqual(fileData, fileDataExpected_1); run_test_2(); }); @@ -65,7 +63,7 @@ function run_test_1() { throw err; }); - buffer = Buffer.from(fileDataInitial); + const buffer = Buffer.from(fileDataInitial); file.write(buffer); cb_occurred += 'write '; @@ -74,13 +72,12 @@ function run_test_1() { function run_test_2() { - var file, buffer, options; - buffer = Buffer.from('123456'); + const buffer = Buffer.from('123456'); - options = { start: 10, - flags: 'r+' }; - file = fs.createWriteStream(filepath, options); + const options = { start: 10, + flags: 'r+' }; + const file = fs.createWriteStream(filepath, options); console.log(' (debug: start ', file.start); console.log(' (debug: pos ', file.pos); @@ -94,10 +91,10 @@ function run_test_2() { console.log(' (debug: start ', file.start); console.log(' (debug: pos ', file.pos); assert.strictEqual(file.bytesWritten, buffer.length); - var fileData = fs.readFileSync(filepath, 'utf8'); + const fileData = fs.readFileSync(filepath, 'utf8'); console.log(' (debug: file data ', fileData); console.log(' (debug: expected ', fileDataExpected_2); - assert.equal(fileData, fileDataExpected_2); + assert.strictEqual(fileData, fileDataExpected_2); run_test_3(); }); @@ -116,13 +113,12 @@ function run_test_2() { function run_test_3() { - var file, options; const data = '\u2026\u2026'; // 3 bytes * 2 = 6 bytes in UTF-8 - options = { start: 10, - flags: 'r+' }; - file = fs.createWriteStream(filepath, options); + const options = { start: 10, + flags: 'r+' }; + const file = fs.createWriteStream(filepath, options); console.log(' (debug: start ', file.start); console.log(' (debug: pos ', file.pos); @@ -139,7 +135,7 @@ function run_test_3() { const fileData = fs.readFileSync(filepath, 'utf8'); console.log(' (debug: file data ', fileData); console.log(' (debug: expected ', fileDataExpected_3); - assert.equal(fileData, fileDataExpected_3); + assert.strictEqual(fileData, fileDataExpected_3); run_test_4(); }); |