File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ require ( '../common' ) ;
3+ const assert = require ( 'assert' ) ;
4+
5+ const { Duplex, finished } = require ( 'stream' ) ;
6+
7+ assert . throws (
8+ ( ) => {
9+ // Passing empty object to mock invalid stream
10+ // should throw error
11+ finished ( { } , ( ) => { } ) ;
12+ } ,
13+ { code : 'ERR_INVALID_ARG_TYPE' }
14+ ) ;
15+
16+ const streamObj = new Duplex ( ) ;
17+ streamObj . end ( ) ;
18+ // Below code should not throw any errors as the
19+ // streamObj is `Stream`
20+ finished ( streamObj , ( ) => { } ) ;
Original file line number Diff line number Diff line change @@ -260,7 +260,12 @@ const http = require('http');
260260 const streamLike = new EE ( ) ;
261261 streamLike . readableEnded = true ;
262262 streamLike . readable = true ;
263- finished ( streamLike , common . mustCall ( ) ) ;
263+ assert . throws (
264+ ( ) => {
265+ finished ( streamLike , ( ) => { } ) ;
266+ } ,
267+ { code : 'ERR_INVALID_ARG_TYPE' }
268+ ) ;
264269 streamLike . emit ( 'close' ) ;
265270}
266271
You can’t perform that action at this time.
0 commit comments