test: refactor test-stream2-writable

* Use common.mustCall() to confirm that _write() is called only once.
* Check that _write() is called with the correct argument

PR-URL: https://github.com/nodejs/node/pull/13823
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
Rich Trott authored and Anna Henningsen committed 2017-06-24 12:19:27 +02:00
1 parent 0ef687e858
commit b23f2461cb
1 file changed
+3 -1
+3 -1
View File
@@ -294,7 +294,9 @@ for (let i = 0; i < chunks.length; i++) {
{
// Verify that end(chunk) twice is an error
const w = new W();
w._write = common.noop;
w._write = common.mustCall((msg) => {
assert.strictEqual(msg.toString(), 'this is the end');
});
let gotError = false;
w.on('error', function(er) {
gotError = true;