@@ -107,7 +107,7 @@ describe('utils.js', function () {
107107 emitted = false ;
108108 } ) ;
109109
110- it ( 'no elements in either queue. Reply in the next tick' , function ( done ) {
110+ it ( 'no elements in either queue. Reply in the next tick with callback ' , function ( done ) {
111111 var called = false ;
112112 utils . reply_in_order ( clientMock , function ( ) {
113113 called = true ;
@@ -116,7 +116,7 @@ describe('utils.js', function () {
116116 assert ( ! called ) ;
117117 } ) ;
118118
119- it ( 'no elements in either queue. Reply in the next tick' , function ( done ) {
119+ it ( 'no elements in either queue. Reply in the next tick without callback ' , function ( done ) {
120120 assert ( ! emitted ) ;
121121 utils . reply_in_order ( clientMock , null , new Error ( 'tada' ) ) ;
122122 assert ( ! emitted ) ;
@@ -153,16 +153,21 @@ describe('utils.js', function () {
153153 }
154154 } ) ;
155155
156- it ( 'elements in the offline queue. Reply after the offline queue is empty and respect the command_obj' , function ( done ) {
157- clientMock . command_queue . push ( create_command_obj ( ) , { } ) ;
158- utils . reply_in_order ( clientMock , function ( ) {
156+ it ( 'elements in the offline queue and the command_queue. Reply all other commands got handled respect the command_obj' , function ( done ) {
157+ clientMock . command_queue . push ( create_command_obj ( ) , create_command_obj ( ) ) ;
158+ clientMock . offline_queue . push ( create_command_obj ( ) , { } ) ;
159+ utils . reply_in_order ( clientMock , function ( err , res ) {
159160 assert . strictEqual ( clientMock . command_queue . length , 0 ) ;
161+ assert . strictEqual ( clientMock . offline_queue . length , 0 ) ;
160162 assert ( ! emitted ) ;
161- assert . strictEqual ( res_count , 1 ) ;
163+ assert . strictEqual ( res_count , 3 ) ;
162164 done ( ) ;
163165 } , null , null ) ;
166+ while ( clientMock . offline_queue . length ) {
167+ clientMock . command_queue . push ( clientMock . offline_queue . shift ( ) ) ;
168+ }
164169 while ( clientMock . command_queue . length ) {
165- clientMock . command_queue . shift ( ) . callback ( null , 'bar ' ) ;
170+ clientMock . command_queue . shift ( ) . callback ( null , 'hello world ' ) ;
166171 }
167172 } ) ;
168173 } ) ;
0 commit comments