@@ -9,16 +9,16 @@ describe("The 'select' method", function () {
99
1010 var rp ;
1111 before ( function ( done ) {
12- RedisProcess . start ( function ( err , _rp ) {
13- rp = _rp ;
14- return done ( err ) ;
15- } ) ;
12+ RedisProcess . start ( function ( err , _rp ) {
13+ rp = _rp ;
14+ return done ( err ) ;
15+ } ) ;
1616 } )
1717
1818 function removeMochaListener ( ) {
19- var mochaListener = process . listeners ( 'uncaughtException' ) . pop ( ) ;
20- process . removeListener ( 'uncaughtException' , mochaListener ) ;
21- return mochaListener ;
19+ var mochaListener = process . listeners ( 'uncaughtException' ) . pop ( ) ;
20+ process . removeListener ( 'uncaughtException' , mochaListener ) ;
21+ return mochaListener ;
2222 }
2323
2424 function allTests ( parser , ip ) {
@@ -32,10 +32,10 @@ describe("The 'select' method", function () {
3232 client = redis . createClient . apply ( redis . createClient , args ) ;
3333 client . once ( "error" , done ) ;
3434 client . once ( "connect" , function ( ) {
35- client . quit ( ) ;
35+ client . quit ( ) ;
3636 } ) ;
3737 client . on ( 'end' , function ( ) {
38- return done ( ) ;
38+ return done ( ) ;
3939 } ) ;
4040 } ) ;
4141
@@ -70,15 +70,14 @@ describe("The 'select' method", function () {
7070 } ) ;
7171 } ) ;
7272
73- describe ( "and no callback is specified" , function ( ) {
73+ describe ( "and a callback is specified" , function ( ) {
7474 describe ( "with a valid db index" , function ( ) {
7575 it ( "selects the appropriate database" , function ( done ) {
7676 assert . strictEqual ( client . selected_db , null , "default db should be null" ) ;
77- client . select ( 1 ) ;
78- setTimeout ( function ( ) {
77+ client . select ( 1 , function ( ) {
7978 assert . equal ( client . selected_db , 1 , "we should have selected the new valid DB" ) ;
8079 return done ( ) ;
81- } , 100 ) ;
80+ } ) ;
8281 } ) ;
8382 } ) ;
8483
@@ -90,15 +89,30 @@ describe("The 'select' method", function () {
9089 return done ( ) ;
9190 } ) ;
9291 } ) ;
92+ } ) ;
93+ } ) ;
94+
95+ describe ( "and no callback is specified" , function ( ) {
96+ describe ( "with a valid db index" , function ( ) {
97+ it ( "selects the appropriate database" , function ( done ) {
98+ assert . strictEqual ( client . selected_db , null , "default db should be null" ) ;
99+ client . select ( 1 ) ;
100+ setTimeout ( function ( ) {
101+ assert . equal ( client . selected_db , 1 , "we should have selected the new valid DB" ) ;
102+ return done ( ) ;
103+ } , 100 ) ;
104+ } ) ;
105+ } ) ;
93106
107+ describe ( "with an invalid db index" , function ( ) {
94108 it ( "throws an error when callback not provided" , function ( done ) {
95109 var mochaListener = removeMochaListener ( ) ;
96110 assert . strictEqual ( client . selected_db , null , "default db should be null" ) ;
97111
98112 process . once ( 'uncaughtException' , function ( err ) {
99- process . on ( 'uncaughtException' , mochaListener ) ;
100- assert . equal ( err . message , 'ERR invalid DB index' ) ;
101- return done ( ) ;
113+ process . on ( 'uncaughtException' , mochaListener ) ;
114+ assert . equal ( err . message , 'ERR invalid DB index' ) ;
115+ return done ( ) ;
102116 } ) ;
103117
104118 client . select ( 9999 ) ;
0 commit comments