File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -236,6 +236,26 @@ describe('parsers', function () {
236236 parser . execute ( new Buffer ( '\n' ) ) ;
237237 assert . strictEqual ( reply_count , 2 ) ;
238238 } ) ;
239+
240+ it ( 'return data as buffer if requested' , function ( ) {
241+ var parser = new Parser ( true ) ;
242+ var reply_count = 0 ;
243+ function check_reply ( reply ) {
244+ if ( Array . isArray ( reply ) ) {
245+ reply = reply [ 0 ] ;
246+ }
247+ assert ( Buffer . isBuffer ( reply ) ) ;
248+ assert . strictEqual ( reply . inspect ( ) , new Buffer ( 'test' ) . inspect ( ) ) ;
249+ reply_count ++ ;
250+ }
251+ parser . send_reply = check_reply ;
252+ parser . execute ( new Buffer ( '+test\r\n' ) ) ;
253+ assert . strictEqual ( reply_count , 1 ) ;
254+ parser . execute ( new Buffer ( '$4\r\ntest\r\n' ) ) ;
255+ assert . strictEqual ( reply_count , 2 ) ;
256+ parser . execute ( new Buffer ( '*1\r\n$4\r\ntest\r\n' ) ) ;
257+ assert . strictEqual ( reply_count , 3 ) ;
258+ } ) ;
239259 } ) ;
240260 } ) ;
241261} ) ;
You can’t perform that action at this time.
0 commit comments