@@ -607,7 +607,10 @@ describe('parsers', function () {
607607 chunks [ i ] = new Buffer ( bigStringArray . join ( ' ' ) + '.' ) // Math.pow(2, 16) chars long
608608 }
609609 var replyCount = 0
610+ var replies = [ ]
611+ var jsParser = Parser . name === 'JavascriptRedisParser'
610612 function checkReply ( reply ) {
613+ replies . push ( reply )
611614 replyCount ++
612615 }
613616 var parser = new Parser ( {
@@ -620,29 +623,35 @@ describe('parsers', function () {
620623 assert . strictEqual ( replyCount , 0 )
621624 parser . execute ( startBigBuffer )
622625 for ( i = 0 ; i < 2 ; i ++ ) {
623- if ( Parser . name === 'JavascriptReplyParser' ) {
626+ if ( jsParser ) {
624627 assert . strictEqual ( parser . bufferCache . length , i + 1 )
625628 }
626629 parser . execute ( chunks [ i ] )
627630 }
628631 assert . strictEqual ( replyCount , 1 )
629632 parser . execute ( new Buffer ( '\r\n' ) )
630633 assert . strictEqual ( replyCount , 2 )
631- parser . execute ( new Buffer ( '+test' ) )
632- assert . strictEqual ( replyCount , 2 )
633- parser . execute ( startSecondBigBuffer )
634- for ( i = 0 ; i < 4 ; i ++ ) {
635- if ( Parser . name === 'JavascriptReplyParser' ) {
636- assert . strictEqual ( parser . bufferCache . length , i + 1 )
634+ setTimeout ( function ( ) {
635+ parser . execute ( new Buffer ( '+test' ) )
636+ assert . strictEqual ( replyCount , 2 )
637+ parser . execute ( startSecondBigBuffer )
638+ for ( i = 0 ; i < 4 ; i ++ ) {
639+ if ( jsParser ) {
640+ assert . strictEqual ( parser . bufferCache . length , i + 1 )
641+ }
642+ parser . execute ( chunks [ i ] )
637643 }
638- parser . execute ( chunks [ i ] )
639- }
640- assert . strictEqual ( replyCount , 3 )
641- parser . execute ( new Buffer ( '\r\n' ) )
642- assert . strictEqual ( replyCount , 4 )
644+ assert . strictEqual ( replyCount , 3 )
645+ parser . execute ( new Buffer ( '\r\n' ) )
646+ assert . strictEqual ( replyCount , 4 )
647+ } , 200 )
643648 // Delay done so the bufferPool is cleared and tested
644- // If the buffer is not cleared, the coverage is not going to be at 100%
645- setTimeout ( done , 600 )
649+ // If the buffer is not cleared, the coverage is not going to be at 100
650+ setTimeout ( function ( ) {
651+ var totalBuffer = Buffer . concat ( chunks ) . toString ( )
652+ assert . strictEqual ( replies [ 3 ] . toString ( ) , totalBuffer )
653+ done ( )
654+ } , ( jsParser ? 1800 : 250 ) )
646655 } )
647656
648657 it ( 'handle big data' , function ( ) {
@@ -668,7 +677,7 @@ describe('parsers', function () {
668677 } )
669678 parser . execute ( startBigBuffer )
670679 for ( i = 0 ; i < 64 ; i ++ ) {
671- if ( Parser . name === 'JavascriptReplyParser ' ) {
680+ if ( Parser . name === 'JavascriptRedisParser ' ) {
672681 assert . strictEqual ( parser . bufferCache . length , i + 1 )
673682 }
674683 parser . execute ( chunks [ i ] )
@@ -701,7 +710,7 @@ describe('parsers', function () {
701710 parser . execute ( new Buffer ( '+test' ) )
702711 parser . execute ( startBigBuffer )
703712 for ( i = 0 ; i < 64 ; i ++ ) {
704- if ( Parser . name === 'JavascriptReplyParser ' ) {
713+ if ( Parser . name === 'JavascriptRedisParser ' ) {
705714 assert . strictEqual ( parser . bufferCache . length , i + 1 )
706715 }
707716 parser . execute ( chunks [ i ] )
@@ -735,7 +744,7 @@ describe('parsers', function () {
735744 } )
736745 parser . execute ( startBigBuffer )
737746 for ( i = 0 ; i < 64 ; i ++ ) {
738- if ( Parser . name === 'JavascriptReplyParser ' ) {
747+ if ( Parser . name === 'JavascriptRedisParser ' ) {
739748 assert . strictEqual ( parser . bufferCache . length , i + 1 )
740749 }
741750 parser . execute ( chunks [ i ] )
0 commit comments