Skip to content

Commit ba63363

Browse files
Trottevanlucas
authored andcommitted
test: refactor test-stream2-writable
* add duration to setTimeout() * assert.equal() -> assert.strictEqual() * remove unused function arguments * normalize indentation PR-URL: #10353 Reviewed-By: Julian Duque <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent b67879f commit ba63363

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

test/parallel/test-stream2-writable.js

+32-32
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function run() {
4646
console.log('# %s', name);
4747
fn({
4848
same: assert.deepStrictEqual,
49-
equal: assert.equal,
49+
equal: assert.strictEqual,
5050
end: function() {
5151
count--;
5252
run();
@@ -56,7 +56,7 @@ function run() {
5656

5757
// ensure all tests have run
5858
process.on('exit', function() {
59-
assert.equal(count, 0);
59+
assert.strictEqual(count, 0);
6060
});
6161

6262
process.nextTick(run);
@@ -136,18 +136,18 @@ test('write bufferize', function(t) {
136136
});
137137

138138
var encodings =
139-
[ 'hex',
140-
'utf8',
141-
'utf-8',
142-
'ascii',
143-
'latin1',
144-
'binary',
145-
'base64',
146-
'ucs2',
147-
'ucs-2',
148-
'utf16le',
149-
'utf-16le',
150-
undefined ];
139+
[ 'hex',
140+
'utf8',
141+
'utf-8',
142+
'ascii',
143+
'latin1',
144+
'binary',
145+
'base64',
146+
'ucs2',
147+
'ucs-2',
148+
'utf16le',
149+
'utf-16le',
150+
undefined ];
151151

152152
tw.on('finish', function() {
153153
t.same(tw.buffer, chunks, 'got the expected chunks');
@@ -174,18 +174,18 @@ test('write no bufferize', function(t) {
174174
};
175175

176176
var encodings =
177-
[ 'hex',
178-
'utf8',
179-
'utf-8',
180-
'ascii',
181-
'latin1',
182-
'binary',
183-
'base64',
184-
'ucs2',
185-
'ucs-2',
186-
'utf16le',
187-
'utf-16le',
188-
undefined ];
177+
[ 'hex',
178+
'utf8',
179+
'utf-8',
180+
'ascii',
181+
'latin1',
182+
'binary',
183+
'base64',
184+
'ucs2',
185+
'ucs-2',
186+
'utf16le',
187+
'utf-16le',
188+
undefined ];
189189

190190
tw.on('finish', function() {
191191
t.same(tw.buffer, chunks, 'got the expected chunks');
@@ -201,7 +201,7 @@ test('write no bufferize', function(t) {
201201

202202
test('write callbacks', function(t) {
203203
var callbacks = chunks.map(function(chunk, i) {
204-
return [i, function(er) {
204+
return [i, function() {
205205
callbacks._called[i] = chunk;
206206
}];
207207
}).reduce(function(set, x) {
@@ -272,7 +272,7 @@ test('end callback called after write callback', function(t) {
272272
test('encoding should be ignored for buffers', function(t) {
273273
var tw = new W();
274274
var hex = '018b5e9a8f6236ffe30e31baf80d2cf6eb';
275-
tw._write = function(chunk, encoding, cb) {
275+
tw._write = function(chunk) {
276276
t.equal(chunk.toString('hex'), hex);
277277
t.end();
278278
};
@@ -284,7 +284,7 @@ test('writables are not pipable', function(t) {
284284
var w = new W();
285285
w._write = function() {};
286286
var gotError = false;
287-
w.on('error', function(er) {
287+
w.on('error', function() {
288288
gotError = true;
289289
});
290290
w.pipe(process.stdout);
@@ -297,7 +297,7 @@ test('duplexes are pipable', function(t) {
297297
d._read = function() {};
298298
d._write = function() {};
299299
var gotError = false;
300-
d.on('error', function(er) {
300+
d.on('error', function() {
301301
gotError = true;
302302
});
303303
d.pipe(process.stdout);
@@ -331,7 +331,7 @@ test('dont end while writing', function(t) {
331331
setTimeout(function() {
332332
this.writing = false;
333333
cb();
334-
});
334+
}, 1);
335335
};
336336
w.on('finish', function() {
337337
assert(wrote);
@@ -368,7 +368,7 @@ test('finish does not come before sync _write cb', function(t) {
368368
assert(writeCb);
369369
t.end();
370370
});
371-
w.write(Buffer.alloc(0), function(er) {
371+
w.write(Buffer.alloc(0), function() {
372372
writeCb = true;
373373
});
374374
w.end();

0 commit comments

Comments
 (0)