Skip to content

Commit

Permalink
test: refactor test-file-*
Browse files Browse the repository at this point in the history
* var to const
* add check that expected error is ENOENT
* indexOf() to includes()

PR-URL: nodejs#8999
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
  • Loading branch information
Jenna Vuong authored and Trott committed Oct 13, 2016
1 parent 804d57d commit a7970c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
11 changes: 6 additions & 5 deletions test/parallel/test-file-read-noexist.js
Original file line number Diff line number Diff line change
@@ -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');
}));
14 changes: 7 additions & 7 deletions test/parallel/test-file-write-stream2.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a7970c0

Please sign in to comment.