0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-stream-writableState-ending.js
Daniel Bevenius 690bdede13 test: fix lint error regarding unused commons const
Currently, make lint is failing with the following error:
3:7  error  'common' is assigned a value but never used  no-unused-vars
✖ 1 problem (1 error, 0 warnings)

PR-URL: https://github.com/nodejs/node/pull/9334
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2016-10-28 12:55:21 +02:00

35 lines
825 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const stream = require('stream');
const writable = new stream.Writable();
function testStates(ending, finished, ended) {
assert.strictEqual(writable._writableState.ending, ending);
assert.strictEqual(writable._writableState.finished, finished);
assert.strictEqual(writable._writableState.ended, ended);
}
writable._write = (chunk, encoding, cb) => {
// ending, finished, ended start in false.
testStates(false, false, false);
cb();
};
writable.on('finish', () => {
// ending, finished, ended = true.
testStates(true, true, true);
});
writable.end('testing function end()', () => {
// ending, finished, ended = true.
testStates(true, true, true);
});
// ending, ended = true.
// finished = false.
testStates(true, false, true);