-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: refactor test-stream-transform-object
* use common.mustCall() as appropriate * eliminate exit handler * var -> const/let * provide duration for setInterval() PR-URL: #10588 Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
- Loading branch information
1 parent
8fae9d4
commit 55377db
Showing
1 changed file
with
16 additions
and
19 deletions.
There are no files selected for viewing
35 changes: 16 additions & 19 deletions
35
test/parallel/test-stream-transform-objectmode-falsey-value.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,30 @@ | ||
'use strict'; | ||
require('../common'); | ||
var assert = require('assert'); | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
var stream = require('stream'); | ||
var PassThrough = stream.PassThrough; | ||
const stream = require('stream'); | ||
const PassThrough = stream.PassThrough; | ||
|
||
var src = new PassThrough({ objectMode: true }); | ||
var tx = new PassThrough({ objectMode: true }); | ||
var dest = new PassThrough({ objectMode: true }); | ||
const src = new PassThrough({ objectMode: true }); | ||
const tx = new PassThrough({ objectMode: true }); | ||
const dest = new PassThrough({ objectMode: true }); | ||
|
||
var expect = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; | ||
var results = []; | ||
process.on('exit', function() { | ||
assert.deepStrictEqual(results, expect); | ||
console.log('ok'); | ||
}); | ||
const expect = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; | ||
const results = []; | ||
|
||
dest.on('data', function(x) { | ||
dest.on('data', common.mustCall(function(x) { | ||
results.push(x); | ||
}); | ||
}, expect.length)); | ||
|
||
src.pipe(tx).pipe(dest); | ||
|
||
var i = -1; | ||
var int = setInterval(function() { | ||
if (i > 10) { | ||
let i = -1; | ||
const int = setInterval(common.mustCall(function() { | ||
if (results.length === expect.length) { | ||
src.end(); | ||
clearInterval(int); | ||
assert.deepStrictEqual(results, expect); | ||
} else { | ||
src.write(i++); | ||
} | ||
}); | ||
}, expect.length + 1), 1); |