From aac93a5c64664c15a1adc793d145ede0ab50630a Mon Sep 17 00:00:00 2001 From: Jenna Vuong Date: Sun, 9 Oct 2016 22:28:42 -0700 Subject: [PATCH] test: refactor test-file-* * var to const * add check that expected error is ENOENT * indexOf() to includes() PR-URL: https://github.com/nodejs/node/pull/8999 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott Reviewed-By: Franziska Hinkelmann --- test/parallel/test-file-read-noexist.js | 11 ++++++----- test/parallel/test-file-write-stream2.js | 14 +++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-file-read-noexist.js b/test/parallel/test-file-read-noexist.js index 166beea0f883f4..423c62dfd54c0f 100644 --- a/test/parallel/test-file-read-noexist.js +++ b/test/parallel/test-file-read-noexist.js @@ -1,10 +1,11 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); -var filename = path.join(common.fixturesDir, 'does_not_exist.txt'); +const filename = path.join(common.fixturesDir, 'does_not_exist.txt'); fs.readFile(filename, 'latin1', common.mustCall(function(err, content) { assert.ok(err); + assert.strictEqual(err.code, 'ENOENT'); })); diff --git a/test/parallel/test-file-write-stream2.js b/test/parallel/test-file-write-stream2.js index 69fdb7051ff11c..77e8119d25b8a7 100644 --- a/test/parallel/test-file-write-stream2.js +++ b/test/parallel/test-file-write-stream2.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var path = require('path'); -var fs = require('fs'); +const path = require('path'); +const fs = require('fs'); -var filepath = path.join(common.tmpDir, 'write.txt'); +const filepath = path.join(common.tmpDir, 'write.txt'); var file; const EXPECTED = '012345678910'; @@ -76,12 +76,12 @@ file.on('close', function() { file.on('error', function(err) { cb_occurred += 'error '; - assert.ok(err.message.indexOf('write after end') >= 0); + assert.ok(err.message.includes('write after end')); }); for (var i = 0; i < 11; i++) { - var ret = file.write(i + ''); + const ret = file.write(i + ''); console.error('%d %j', i, ret); // return false when i hits 10