Skip to content

Commit 4a16f9b

Browse files
edsadrevanlucas
authored andcommitted
test: improve test-fs-empty-readStream.js
* use const instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: #10479 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent 96c3c65 commit 4a16f9b

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed
+16-16
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var path = require('path');
5-
var fs = require('fs');
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const path = require('path');
5+
const fs = require('fs');
66

7-
var emptyFile = path.join(common.fixturesDir, 'empty.txt');
7+
const emptyFile = path.join(common.fixturesDir, 'empty.txt');
88

9-
fs.open(emptyFile, 'r', function(error, fd) {
9+
fs.open(emptyFile, 'r', common.mustCall((error, fd) => {
1010
assert.ifError(error);
1111

12-
var read = fs.createReadStream(emptyFile, { 'fd': fd });
12+
const read = fs.createReadStream(emptyFile, { 'fd': fd });
1313

14-
read.once('data', function() {
14+
read.once('data', () => {
1515
throw new Error('data event should not emit');
1616
});
1717

1818
read.once('end', common.mustCall(function endEvent1() {}));
19-
});
19+
}));
2020

21-
fs.open(emptyFile, 'r', function(error, fd) {
21+
fs.open(emptyFile, 'r', common.mustCall((error, fd) => {
2222
assert.ifError(error);
2323

24-
var read = fs.createReadStream(emptyFile, { 'fd': fd });
24+
const read = fs.createReadStream(emptyFile, { 'fd': fd });
2525
read.pause();
2626

27-
read.once('data', function() {
27+
read.once('data', () => {
2828
throw new Error('data event should not emit');
2929
});
3030

3131
read.once('end', function endEvent2() {
3232
throw new Error('end event should not emit');
3333
});
3434

35-
setTimeout(function() {
36-
assert.equal(read.isPaused(), true);
37-
}, common.platformTimeout(50));
38-
});
35+
setTimeout(common.mustCall(() => {
36+
assert.strictEqual(read.isPaused(), true);
37+
}), common.platformTimeout(50));
38+
}));

0 commit comments

Comments
 (0)