Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor test-stream-transform-object #10588

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions test/parallel/test-stream-transform-objectmode-falsey-value.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
'use strict';
require('../common');
const common = require('../common');
const assert = require('assert');

const stream = require('stream');
var PassThrough = stream.PassThrough;
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);