@@ -84,6 +84,28 @@ describe("The node_redis client", function () {
84
84
} ) ;
85
85
} ) ;
86
86
87
+ it ( "reconnects properly when monitoring" , function ( done ) {
88
+ client . on ( "reconnecting" , function on_recon ( params ) {
89
+ client . on ( "ready" , function on_ready ( ) {
90
+ assert . strictEqual ( client . monitoring , true , "monitoring after reconnect" ) ;
91
+ client . removeListener ( "ready" , on_ready ) ;
92
+ client . removeListener ( "reconnecting" , on_recon ) ;
93
+ done ( ) ;
94
+ } ) ;
95
+ } ) ;
96
+
97
+ assert . strictEqual ( client . monitoring , false , "monitoring off at start" ) ;
98
+ client . set ( "recon 1" , "one" ) ;
99
+ client . monitor ( function ( err , res ) {
100
+ assert . strictEqual ( client . monitoring , true , "monitoring on after monitor()" ) ;
101
+ client . set ( "recon 2" , "two" , function ( err , res ) {
102
+ // Do not do this in normal programs. This is to simulate the server closing on us.
103
+ // For orderly shutdown in normal programs, do client.quit()
104
+ client . stream . destroy ( ) ;
105
+ } ) ;
106
+ } ) ;
107
+ } ) ;
108
+
87
109
// TODO: we should only have a single subscription in this this
88
110
// test but unsubscribing from the single channel indicates
89
111
// that one subscriber still exists, let's dig into this.
0 commit comments