Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cdc2909

Browse filesBrowse files
Jonathan Darlingaddaleax
authored andcommitted
test: refactor test-fs-read-stream-inherit.js
* convert assert.equal to assert.strictEqual * convert var to const/let PR-URL: #9894 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 55b58ba commit cdc2909
Copy full SHA for cdc2909

File tree

Expand file treeCollapse file tree

1 file changed

+45
-47
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+45
-47
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-fs-read-stream-inherit.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-read-stream-inherit.js
+45-47Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
3+
const assert = require('assert');
44

5-
var path = require('path');
6-
var fs = require('fs');
7-
var fn = path.join(common.fixturesDir, 'elipses.txt');
8-
var rangeFile = path.join(common.fixturesDir, 'x.txt');
5+
const path = require('path');
6+
const fs = require('fs');
7+
const fn = path.join(common.fixturesDir, 'elipses.txt');
8+
const rangeFile = path.join(common.fixturesDir, 'x.txt');
99

10-
var callbacks = { open: 0, end: 0, close: 0 };
10+
const callbacks = { open: 0, end: 0, close: 0 };
1111

12-
var paused = false;
12+
let paused = false;
1313

14-
var file = fs.ReadStream(fn);
14+
const file = fs.ReadStream(fn);
1515

1616
file.on('open', function(fd) {
1717
file.length = 0;
1818
callbacks.open++;
19-
assert.equal('number', typeof fd);
19+
assert.strictEqual(typeof fd, 'number');
2020
assert.ok(file.readable);
2121

2222
// GH-535
@@ -48,19 +48,17 @@ file.on('end', function(chunk) {
4848

4949
file.on('close', function() {
5050
callbacks.close++;
51-
52-
//assert.equal(fs.readFileSync(fn), fileContent);
5351
});
5452

55-
var file3 = fs.createReadStream(fn, Object.create({encoding: 'utf8'}));
53+
const file3 = fs.createReadStream(fn, Object.create({encoding: 'utf8'}));
5654
file3.length = 0;
5755
file3.on('data', function(data) {
58-
assert.equal('string', typeof data);
56+
assert.strictEqual(typeof data, 'string');
5957
file3.length += data.length;
6058

61-
for (var i = 0; i < data.length; i++) {
59+
for (let i = 0; i < data.length; i++) {
6260
// http://www.fileformat.info/info/unicode/char/2026/index.htm
63-
assert.equal('\u2026', data[i]);
61+
assert.strictEqual(data[i], '\u2026');
6462
}
6563
});
6664

@@ -69,74 +67,74 @@ file3.on('close', function() {
6967
});
7068

7169
process.on('exit', function() {
72-
assert.equal(1, callbacks.open);
73-
assert.equal(1, callbacks.end);
74-
assert.equal(2, callbacks.close);
75-
assert.equal(30000, file.length);
76-
assert.equal(10000, file3.length);
70+
assert.strictEqual(callbacks.open, 1);
71+
assert.strictEqual(callbacks.end, 1);
72+
assert.strictEqual(callbacks.close, 2);
73+
assert.strictEqual(file.length, 30000);
74+
assert.strictEqual(file3.length, 10000);
7775
console.error('ok');
7876
});
7977

80-
var file4 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1,
81-
start: 1, end: 2}));
82-
assert.equal(file4.start, 1);
83-
assert.equal(file4.end, 2);
84-
var contentRead = '';
78+
const file4 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1,
79+
start: 1, end: 2}));
80+
assert.strictEqual(file4.start, 1);
81+
assert.strictEqual(file4.end, 2);
82+
let contentRead = '';
8583
file4.on('data', function(data) {
8684
contentRead += data.toString('utf-8');
8785
});
8886
file4.on('end', function(data) {
89-
assert.equal(contentRead, 'yz');
87+
assert.strictEqual(contentRead, 'yz');
9088
});
9189

92-
var file5 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1,
93-
start: 1}));
94-
assert.equal(file5.start, 1);
90+
const file5 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1,
91+
start: 1}));
92+
assert.strictEqual(file5.start, 1);
9593
file5.data = '';
9694
file5.on('data', function(data) {
9795
file5.data += data.toString('utf-8');
9896
});
9997
file5.on('end', function() {
100-
assert.equal(file5.data, 'yz\n');
98+
assert.strictEqual(file5.data, 'yz\n');
10199
});
102100

103101
// https://github.com/joyent/node/issues/2320
104-
var file6 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1.23,
105-
start: 1}));
106-
assert.equal(file6.start, 1);
102+
const file6 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1.23,
103+
start: 1}));
104+
assert.strictEqual(file6.start, 1);
107105
file6.data = '';
108106
file6.on('data', function(data) {
109107
file6.data += data.toString('utf-8');
110108
});
111109
file6.on('end', function() {
112-
assert.equal(file6.data, 'yz\n');
110+
assert.strictEqual(file6.data, 'yz\n');
113111
});
114112

115113
assert.throws(function() {
116114
fs.createReadStream(rangeFile, Object.create({start: 10, end: 2}));
117115
}, /"start" option must be <= "end" option/);
118116

119-
var stream = fs.createReadStream(rangeFile, Object.create({ start: 0,
120-
end: 0 }));
121-
assert.equal(stream.start, 0);
122-
assert.equal(stream.end, 0);
117+
const stream = fs.createReadStream(rangeFile, Object.create({ start: 0,
118+
end: 0 }));
119+
assert.strictEqual(stream.start, 0);
120+
assert.strictEqual(stream.end, 0);
123121
stream.data = '';
124122

125123
stream.on('data', function(chunk) {
126124
stream.data += chunk;
127125
});
128126

129127
stream.on('end', function() {
130-
assert.equal('x', stream.data);
128+
assert.strictEqual(stream.data, 'x');
131129
});
132130

133131
// pause and then resume immediately.
134-
var pauseRes = fs.createReadStream(rangeFile);
132+
const pauseRes = fs.createReadStream(rangeFile);
135133
pauseRes.pause();
136134
pauseRes.resume();
137135

138-
var file7 = fs.createReadStream(rangeFile, Object.create({autoClose: false }));
139-
assert.equal(file7.autoClose, false);
136+
let file7 = fs.createReadStream(rangeFile, Object.create({autoClose: false }));
137+
assert.strictEqual(file7.autoClose, false);
140138
file7.on('data', function() {});
141139
file7.on('end', function() {
142140
process.nextTick(function() {
@@ -154,18 +152,18 @@ function file7Next() {
154152
file7.data += data;
155153
});
156154
file7.on('end', function(err) {
157-
assert.equal(file7.data, 'xyz\n');
155+
assert.strictEqual(file7.data, 'xyz\n');
158156
});
159157
}
160158

161159
// Just to make sure autoClose won't close the stream because of error.
162-
var file8 = fs.createReadStream(null, Object.create({fd: 13337,
163-
autoClose: false }));
160+
const file8 = fs.createReadStream(null, Object.create({fd: 13337,
161+
autoClose: false }));
164162
file8.on('data', function() {});
165163
file8.on('error', common.mustCall(function() {}));
166164

167165
// Make sure stream is destroyed when file does not exist.
168-
var file9 = fs.createReadStream('/path/to/file/that/does/not/exist');
166+
const file9 = fs.createReadStream('/path/to/file/that/does/not/exist');
169167
file9.on('data', function() {});
170168
file9.on('error', common.mustCall(function() {}));
171169

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.