Skip to content

Commit b0cb787

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 <benjamingr@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 3605726 commit b0cb787

1 file changed

Lines changed: 7 additions & 18 deletions

File tree

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
require('../common');
2+
constcommon=require('../common');
33
constassert=require('assert');
44
conststream=require('stream');
55
conststr='asdfasdfasdfasdfasdf';
@@ -10,29 +10,25 @@ const r = new stream.Readable({
1010
});
1111

1212
letreads=0;
13-
leteofed=false;
14-
letended=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
}elseif(reads===1){
2321
varret=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)