Skip to content

Commit dba8d20

Browse files
edsadritaloacasas
authored andcommitted
test: improve the code in test-fs-read-stream
* use const and let instead of var * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: #10556 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent eba9add commit dba8d20

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

test/parallel/test-fs-read-stream-fd.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ const common = require('../common');
33
const fs = require('fs');
44
const assert = require('assert');
55
const path = require('path');
6-
var file = path.join(common.tmpDir, '/read_stream_fd_test.txt');
7-
var input = 'hello world';
8-
var output = '';
9-
var fd, stream;
6+
const file = path.join(common.tmpDir, '/read_stream_fd_test.txt');
7+
const input = 'hello world';
108

9+
let output = '';
1110
common.refreshTmpDir();
1211
fs.writeFileSync(file, input);
13-
fd = fs.openSync(file, 'r');
1412

15-
stream = fs.createReadStream(null, { fd: fd, encoding: 'utf8' });
16-
stream.on('data', function(data) {
13+
const fd = fs.openSync(file, 'r');
14+
const stream = fs.createReadStream(null, { fd: fd, encoding: 'utf8' });
15+
16+
stream.on('data', (data) => {
1717
output += data;
1818
});
1919

20-
process.on('exit', function() {
21-
fs.unlinkSync(file);
22-
assert.equal(output, input);
20+
process.on('exit', () => {
21+
assert.strictEqual(output, input);
2322
});

0 commit comments

Comments
 (0)