summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2016-04-04 23:08:45 -0700
committerRich Trott <rtrott@gmail.com>2016-04-07 14:06:23 -0700
commit7c9a691ee7d13ccf1c883e27fdb96eccc8b73d5e (patch)
treee798b147cd19dc406cef182319be648b330f1fa8 /test
parent937ac3760a85888047c6acde9b15320643fa1324 (diff)
downloadandroid-node-v8-7c9a691ee7d13ccf1c883e27fdb96eccc8b73d5e.tar.gz
android-node-v8-7c9a691ee7d13ccf1c883e27fdb96eccc8b73d5e.tar.bz2
android-node-v8-7c9a691ee7d13ccf1c883e27fdb96eccc8b73d5e.zip
test: refactor test-file-write-stream3
* use common.mustCall() to verify all tests have run * eliminate unneeded removeTestFile() * eliminate unneeded var leaking into global scope * var -> const * remove instance of let PR-URL: https://github.com/nodejs/node/pull/6050 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-file-write-stream3.js31
1 files changed, 9 insertions, 22 deletions
diff --git a/test/parallel/test-file-write-stream3.js b/test/parallel/test-file-write-stream3.js
index 2d65d3e294..2407680d00 100644
--- a/test/parallel/test-file-write-stream3.js
+++ b/test/parallel/test-file-write-stream3.js
@@ -5,21 +5,20 @@ const path = require('path');
const fs = require('fs');
-var filepath = path.join(common.tmpDir, 'write_pos.txt');
+const filepath = path.join(common.tmpDir, 'write_pos.txt');
const cb_expected = 'write open close write open close write open close ';
-let cb_occurred = '';
+var cb_occurred = '';
-var fileDataInitial = 'abcdefghijklmnopqrstuvwxyz';
+const fileDataInitial = 'abcdefghijklmnopqrstuvwxyz';
-var fileDataExpected_1 = 'abcdefghijklmnopqrstuvwxyz';
-var fileDataExpected_2 = 'abcdefghij123456qrstuvwxyz';
-var fileDataExpected_3 = 'abcdefghij\u2026\u2026qrstuvwxyz';
+const fileDataExpected_1 = 'abcdefghijklmnopqrstuvwxyz';
+const fileDataExpected_2 = 'abcdefghij123456qrstuvwxyz';
+const fileDataExpected_3 = 'abcdefghij\u2026\u2026qrstuvwxyz';
process.on('exit', function() {
- removeTestFile();
if (cb_occurred !== cb_expected) {
console.log(' Test callback events missing or out of order:');
console.log(' expected: %j', cb_expected);
@@ -30,12 +29,6 @@ process.on('exit', function() {
}
});
-function removeTestFile() {
- try {
- fs.unlinkSync(filepath);
- } catch (ex) { }
-}
-
common.refreshTmpDir();
@@ -164,20 +157,14 @@ function run_test_3() {
}
-function run_test_4() {
- var options;
-
- options = { start: -5,
- flags: 'r+' };
-
+const run_test_4 = common.mustCall(function() {
// Error: start must be >= zero
assert.throws(
function() {
- file = fs.createWriteStream(filepath, options);
+ fs.createWriteStream(filepath, { start: -5, flags: 'r+' });
},
/"start" must be/
);
-
-}
+});
run_test_1();