Browse Source

test: improve test stream transform constructor

* new test for the error when a transform function is not specified
* use let instead of var
* use assert.strictEqual instead of assert.equal
* use arrow functions

PR-URL: https://github.com/nodejs/node/pull/10699
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v7.x
Adrian Estrada 8 years ago
committed by Italo A. Casas
parent
commit
c6618df2cc
No known key found for this signature in database GPG Key ID: 23EFEFE93C4CFFFE
  1. 13
      test/parallel/test-stream-transform-constructor-set-methods.js

13
test/parallel/test-stream-transform-constructor-set-methods.js

@ -21,12 +21,19 @@ const t = new Transform({
flush: _flush flush: _flush
}); });
const t2 = new Transform({});
t.end(Buffer.from('blerg')); t.end(Buffer.from('blerg'));
t.resume(); t.resume();
process.on('exit', function() { assert.throws(() => {
t2.end(Buffer.from('blerg'));
}, /^Error: _transform\(\) is not implemented$/);
process.on('exit', () => {
assert.strictEqual(t._transform, _transform); assert.strictEqual(t._transform, _transform);
assert.strictEqual(t._flush, _flush); assert.strictEqual(t._flush, _flush);
assert(_transformCalled); assert.strictEqual(_transformCalled, true);
assert(_flushCalled); assert.strictEqual(_flushCalled, true);
}); });

Loading…
Cancel
Save