From 8de858b96d94cfbfe420a2fe1c95023e3aa92590 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 17 Jan 2022 08:54:40 -0800 Subject: [PATCH] test: increase coverage for stream writable Refs: https://github.com/nodejs/node/pull/41433#issuecomment-1009551922 PR-URL: https://github.com/nodejs/node/pull/41486 Reviewed-By: Luigi Pinca Reviewed-By: Antoine du Hamel --- .../test-stream-writable-final-throw.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/parallel/test-stream-writable-final-throw.js diff --git a/test/parallel/test-stream-writable-final-throw.js b/test/parallel/test-stream-writable-final-throw.js new file mode 100644 index 00000000000000..e7dd21abc3c76c --- /dev/null +++ b/test/parallel/test-stream-writable-final-throw.js @@ -0,0 +1,23 @@ +'use strict'; + +const common = require('../common'); +const { + Duplex, +} = require('stream'); + +{ + class Foo extends Duplex { + _final(callback) { + throw new Error('fhqwhgads'); + } + + _read() {} + } + + const foo = new Foo(); + foo._write = common.mustCall((chunk, encoding, cb) => { + cb(); + }); + foo.end('test', common.expectsError({ message: 'fhqwhgads' })); + foo.on('error', common.mustCall()); +}