@@ -607,7 +607,10 @@ describe('parsers', function () {
607
607
chunks [ i ] = new Buffer ( bigStringArray . join ( ' ' ) + '.' ) // Math.pow(2, 16) chars long
608
608
}
609
609
var replyCount = 0
610
+ var replies = [ ]
611
+ var jsParser = Parser . name === 'JavascriptRedisParser'
610
612
function checkReply ( reply ) {
613
+ replies . push ( reply )
611
614
replyCount ++
612
615
}
613
616
var parser = new Parser ( {
@@ -620,29 +623,35 @@ describe('parsers', function () {
620
623
assert . strictEqual ( replyCount , 0 )
621
624
parser . execute ( startBigBuffer )
622
625
for ( i = 0 ; i < 2 ; i ++ ) {
623
- if ( Parser . name === 'JavascriptReplyParser' ) {
626
+ if ( jsParser ) {
624
627
assert . strictEqual ( parser . bufferCache . length , i + 1 )
625
628
}
626
629
parser . execute ( chunks [ i ] )
627
630
}
628
631
assert . strictEqual ( replyCount , 1 )
629
632
parser . execute ( new Buffer ( '\r\n' ) )
630
633
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 ] )
637
643
}
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 )
643
648
// 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 ) )
646
655
} )
647
656
648
657
it ( 'handle big data' , function ( ) {
@@ -668,7 +677,7 @@ describe('parsers', function () {
668
677
} )
669
678
parser . execute ( startBigBuffer )
670
679
for ( i = 0 ; i < 64 ; i ++ ) {
671
- if ( Parser . name === 'JavascriptReplyParser ' ) {
680
+ if ( Parser . name === 'JavascriptRedisParser ' ) {
672
681
assert . strictEqual ( parser . bufferCache . length , i + 1 )
673
682
}
674
683
parser . execute ( chunks [ i ] )
@@ -701,7 +710,7 @@ describe('parsers', function () {
701
710
parser . execute ( new Buffer ( '+test' ) )
702
711
parser . execute ( startBigBuffer )
703
712
for ( i = 0 ; i < 64 ; i ++ ) {
704
- if ( Parser . name === 'JavascriptReplyParser ' ) {
713
+ if ( Parser . name === 'JavascriptRedisParser ' ) {
705
714
assert . strictEqual ( parser . bufferCache . length , i + 1 )
706
715
}
707
716
parser . execute ( chunks [ i ] )
@@ -735,7 +744,7 @@ describe('parsers', function () {
735
744
} )
736
745
parser . execute ( startBigBuffer )
737
746
for ( i = 0 ; i < 64 ; i ++ ) {
738
- if ( Parser . name === 'JavascriptReplyParser ' ) {
747
+ if ( Parser . name === 'JavascriptRedisParser ' ) {
739
748
assert . strictEqual ( parser . bufferCache . length , i + 1 )
740
749
}
741
750
parser . execute ( chunks [ i ] )
0 commit comments