@@ -13,10 +13,11 @@ describe("connection tests", function () {
1313
1414 var client ;
1515
16+ beforeEach ( function ( ) {
17+ client = null ;
18+ } ) ;
1619 afterEach ( function ( ) {
17- if ( client ) {
18- client . end ( ) ;
19- }
20+ client . end ( ) ;
2021 } ) ;
2122
2223 describe ( "on lost connection" , function ( ) {
@@ -127,13 +128,13 @@ describe("connection tests", function () {
127128
128129 it ( "emit an error after the socket timeout exceeded the connect_timeout time" , function ( done ) {
129130 var connect_timeout = 1000 ; // in ms
130- var client = redis . createClient ( {
131+ client = redis . createClient ( {
131132 parser : parser ,
132- host : '1.2.3.4 ' ,
133+ host : '192.168.74.167 ' ,
133134 connect_timeout : connect_timeout
134135 } ) ;
135136 assert ( client . stream . _events . timeout ) ;
136- assert . strictEqual ( client . address , '1.2.3.4 :6379' ) ;
137+ assert . strictEqual ( client . address , '192.168.74.167 :6379' ) ;
137138 var time = Date . now ( ) ;
138139
139140 client . on ( "reconnecting" , function ( params ) {
@@ -148,21 +149,22 @@ describe("connection tests", function () {
148149 } ) ;
149150
150151 it ( "use the system socket timeout if the connect_timeout has not been provided" , function ( ) {
151- var client = redis . createClient ( {
152+ client = redis . createClient ( {
152153 parser : parser ,
153- host : '1.2.3.4 '
154+ host : '192.168.74.167 '
154155 } ) ;
155156 assert ( client . stream . _events . timeout === undefined ) ;
156157 } ) ;
157158
158159 it ( "clears the socket timeout after a connection has been established" , function ( done ) {
159- var client = redis . createClient ( {
160+ client = redis . createClient ( {
160161 parser : parser ,
161162 connect_timeout : 1000
162163 } ) ;
163164 assert . strictEqual ( client . stream . _idleTimeout , 1000 ) ;
164165 client . on ( 'connect' , function ( ) {
165166 assert . strictEqual ( client . stream . _idleTimeout , - 1 ) ;
167+ assert ( client . stream . _events . timeout === undefined ) ;
166168 done ( ) ;
167169 } ) ;
168170 } ) ;
@@ -255,6 +257,9 @@ describe("connection tests", function () {
255257 } ) ;
256258
257259 it ( "throws on strange connection info" , function ( ) {
260+ client = {
261+ end : function ( ) { }
262+ } ;
258263 try {
259264 redis . createClient ( true ) ;
260265 throw new Error ( 'failed' ) ;
0 commit comments