File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,29 @@ describe('copyEventEmitter()', function() {
129129
130130 copyEventEmitter ( source , target ) ;
131131
132+ expect ( target . listenerCount ( eventName ) ) . to . be . equal ( 1 ) ;
133+ } ) ;
134+ it ( 'should handle onceWrapper-like listener with falsy listener property' , ( ) => {
135+ const source = new EventEmitter ( ) ;
136+ const target = new EventEmitter ( ) ;
137+
138+ // Create a mock listener that looks like onceWrapper and has a falsy listener property
139+ const mockListener : any = function ( ) { } ;
140+ mockListener . listener = 0 ; // falsy value present
141+ const originalInspect = require ( 'util' ) . inspect ;
142+ require ( 'util' ) . inspect = ( obj : any ) => {
143+ if ( obj === mockListener ) {
144+ return 'function onceWrapper() { ... }' ;
145+ }
146+ return originalInspect ( obj ) ;
147+ } ;
148+
149+ source . on ( eventName , mockListener as any ) ;
150+ copyEventEmitter ( source , target ) ;
151+
152+ // Restore original inspect
153+ require ( 'util' ) . inspect = originalInspect ;
154+
132155 expect ( target . listenerCount ( eventName ) ) . to . be . equal ( 1 ) ;
133156 } ) ;
134157} ) ;
You can’t perform that action at this time.
0 commit comments