Skip to content

Commit c0800d9

Browse files
TrottMylesBorins
authored andcommitted
test: refactor test-stream-big-push
* use common.mustCall() * specify setTimeout() duration of 1ms * remove unused `n` function argument PR-URL: #10226 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent f664613 commit c0800d9

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

test/parallel/test-stream-big-push.js

+7-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
33
const assert = require('assert');
44
const stream = require('stream');
55
const str = 'asdfasdfasdfasdfasdf';
@@ -10,29 +10,25 @@ const r = new stream.Readable({
1010
});
1111

1212
let reads = 0;
13-
let eofed = false;
14-
let ended = false;
1513

16-
r._read = function(n) {
14+
function _read() {
1715
if (reads === 0) {
1816
setTimeout(function() {
1917
r.push(str);
20-
});
18+
}, 1);
2119
reads++;
2220
} else if (reads === 1) {
2321
var ret = r.push(str);
2422
assert.strictEqual(ret, false);
2523
reads++;
2624
} else {
27-
assert(!eofed);
28-
eofed = true;
2925
r.push(null);
3026
}
31-
};
27+
}
3228

33-
r.on('end', function() {
34-
ended = true;
35-
});
29+
r._read = common.mustCall(_read, 3);
30+
31+
r.on('end', common.mustCall(function() {}));
3632

3733
// push some data in to start.
3834
// we've never gotten any read event at this point.
@@ -55,10 +51,3 @@ r.once('readable', function() {
5551
chunk = r.read();
5652
assert.strictEqual(chunk, null);
5753
});
58-
59-
process.on('exit', function() {
60-
assert(eofed);
61-
assert(ended);
62-
assert.strictEqual(reads, 2);
63-
console.log('ok');
64-
});

0 commit comments

Comments
 (0)