Skip to content

Commit

Permalink
test: writable stream needDrain state
Browse files Browse the repository at this point in the history
Add a test for _writableState.needDrain.

PR-URL: #8799
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Related: #8686
  • Loading branch information
italoacasas authored and mcollina committed Oct 28, 2016
1 parent fd16eed commit 9ed7261
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/parallel/test-stream-writable-needdrain-state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const common = require('../common');
const stream = require('stream');
const assert = require('assert');

const transform = new stream.Transform({
transform: _transform,
highWaterMark: 1
});

function _transform(chunk, encoding, cb) {
assert.strictEqual(transform._writableState.needDrain, true);
cb();
}

assert.strictEqual(transform._writableState.needDrain, false);

transform.write('asdasd', common.mustCall(() => {
assert.strictEqual(transform._writableState.needDrain, false);
}));

assert.strictEqual(transform._writableState.needDrain, true);

0 comments on commit 9ed7261

Please sign in to comment.