From 904438965bbdc6bfb44a052b91a1fed177e56950 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 12 Jan 2022 03:35:53 +0000 Subject: [PATCH] test: increase coverage for stream writable Refs: https://github.com/nodejs/node/pull/41433#issuecomment-1009551922 --- .../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()); +}