File tree Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ function wrapRemoveListener (removeListener) {
188
188
189
189
listeners . delete ( listener )
190
190
191
- return removeListener . call ( this , eventName , listener )
191
+ return removeListener . apply ( this , arguments )
192
192
}
193
193
}
194
194
@@ -202,7 +202,7 @@ function wrapRemoveAllListeners (removeAllListeners) {
202
202
}
203
203
}
204
204
205
- return removeAllListeners . call ( this , eventName )
205
+ return removeAllListeners . apply ( this , arguments )
206
206
}
207
207
}
208
208
Original file line number Diff line number Diff line change @@ -300,6 +300,43 @@ module.exports = factory => {
300
300
301
301
expect ( spy ) . to . not . have . been . called
302
302
} )
303
+
304
+ it ( 'should remove all listeners of a type' , ( ) => {
305
+ const spy = sinon . spy ( )
306
+ const spy2 = sinon . spy ( )
307
+
308
+ scope . bind ( emitter )
309
+
310
+ scope . activate ( span , ( ) => {
311
+ emitter . once ( 'test' , spy )
312
+ emitter . once ( 'test' , spy2 )
313
+ emitter . removeAllListeners ( 'test' )
314
+ } )
315
+
316
+ emitter . emit ( 'test' )
317
+
318
+ expect ( spy ) . to . not . have . been . called
319
+ expect ( spy2 ) . to . not . have . been . called
320
+ } )
321
+
322
+ it ( 'should remove all listeners' , ( ) => {
323
+ const spy = sinon . spy ( )
324
+ const spy2 = sinon . spy ( )
325
+
326
+ scope . bind ( emitter )
327
+
328
+ scope . activate ( span , ( ) => {
329
+ emitter . once ( 'test' , spy )
330
+ emitter . once ( 'test2' , spy2 )
331
+ emitter . removeAllListeners ( )
332
+ } )
333
+
334
+ emitter . emit ( 'test' )
335
+ emitter . emit ( 'test2' )
336
+
337
+ expect ( spy ) . to . not . have . been . called
338
+ expect ( spy2 ) . to . not . have . been . called
339
+ } )
303
340
} )
304
341
305
342
describe ( 'with an unsupported target' , ( ) => {
You can’t perform that action at this time.
0 commit comments