File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -453,8 +453,12 @@ tests.FWD_ERRORS_1 = function () {
453
453
var toThrow = new Error ( "Forced exception" ) ;
454
454
var recordedError = null ;
455
455
456
- var originalHandlers = client3 . listeners ( "error" ) ;
456
+ var originalHandlers = {
457
+ "error" : client3 . listeners ( "error" ) ,
458
+ "message" : client3 . listeners ( "message" )
459
+ } ;
457
460
client3 . removeAllListeners ( "error" ) ;
461
+ client3 . removeAllListeners ( "message" ) ;
458
462
client3 . once ( "error" , function ( err ) {
459
463
recordedError = err ;
460
464
} ) ;
@@ -470,8 +474,15 @@ tests.FWD_ERRORS_1 = function () {
470
474
471
475
client . publish ( name , "Some message" ) ;
472
476
setTimeout ( function ( ) {
473
- client3 . listeners ( "error" ) . push ( originalHandlers ) ;
474
477
assert . equal ( recordedError , toThrow , "Should have caught our forced exception" ) ;
478
+ client3 . unsubscribe ( name ) ;
479
+ client3 . removeAllListeners ( "message" ) ;
480
+ originalHandlers . error . forEach ( function ( fn ) {
481
+ client3 . on ( "error" , fn ) ;
482
+ } ) ;
483
+ originalHandlers . message . forEach ( function ( fn ) {
484
+ client3 . on ( "message" , fn ) ;
485
+ } ) ;
475
486
next ( name ) ;
476
487
} , 150 ) ;
477
488
} ;
You can’t perform that action at this time.
0 commit comments