@@ -13,10 +13,11 @@ describe("connection tests", function () {
13
13
14
14
var client ;
15
15
16
+ beforeEach ( function ( ) {
17
+ client = null ;
18
+ } ) ;
16
19
afterEach ( function ( ) {
17
- if ( client ) {
18
- client . end ( ) ;
19
- }
20
+ client . end ( ) ;
20
21
} ) ;
21
22
22
23
describe ( "on lost connection" , function ( ) {
@@ -127,13 +128,13 @@ describe("connection tests", function () {
127
128
128
129
it ( "emit an error after the socket timeout exceeded the connect_timeout time" , function ( done ) {
129
130
var connect_timeout = 1000 ; // in ms
130
- var client = redis . createClient ( {
131
+ client = redis . createClient ( {
131
132
parser : parser ,
132
- host : '1.2.3.4 ' ,
133
+ host : '192.168.74.167 ' ,
133
134
connect_timeout : connect_timeout
134
135
} ) ;
135
136
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' ) ;
137
138
var time = Date . now ( ) ;
138
139
139
140
client . on ( "reconnecting" , function ( params ) {
@@ -148,21 +149,22 @@ describe("connection tests", function () {
148
149
} ) ;
149
150
150
151
it ( "use the system socket timeout if the connect_timeout has not been provided" , function ( ) {
151
- var client = redis . createClient ( {
152
+ client = redis . createClient ( {
152
153
parser : parser ,
153
- host : '1.2.3.4 '
154
+ host : '192.168.74.167 '
154
155
} ) ;
155
156
assert ( client . stream . _events . timeout === undefined ) ;
156
157
} ) ;
157
158
158
159
it ( "clears the socket timeout after a connection has been established" , function ( done ) {
159
- var client = redis . createClient ( {
160
+ client = redis . createClient ( {
160
161
parser : parser ,
161
162
connect_timeout : 1000
162
163
} ) ;
163
164
assert . strictEqual ( client . stream . _idleTimeout , 1000 ) ;
164
165
client . on ( 'connect' , function ( ) {
165
166
assert . strictEqual ( client . stream . _idleTimeout , - 1 ) ;
167
+ assert ( client . stream . _events . timeout === undefined ) ;
166
168
done ( ) ;
167
169
} ) ;
168
170
} ) ;
@@ -255,6 +257,9 @@ describe("connection tests", function () {
255
257
} ) ;
256
258
257
259
it ( "throws on strange connection info" , function ( ) {
260
+ client = {
261
+ end : function ( ) { }
262
+ } ;
258
263
try {
259
264
redis . createClient ( true ) ;
260
265
throw new Error ( 'failed' ) ;
0 commit comments