File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -674,6 +674,35 @@ describe('compression()', function(){
674
674
. end ( )
675
675
} )
676
676
} )
677
+
678
+ describe ( 'when callbacks are used' , function ( ) {
679
+ it ( 'should call the passed callbacks' , function ( done ) {
680
+ var callbacks = 0 ;
681
+ var server = createServer ( { threshold : '1kb' } , function ( req , res ) {
682
+ res . setHeader ( 'Content-Type' , 'text/plain' )
683
+ res . write ( 'Hello' , null , function ( ) {
684
+ callbacks ++
685
+ res . flush ( )
686
+ } ) ;
687
+ res . write ( ' World' , null , function ( ) {
688
+ callbacks ++
689
+ res . flush ( )
690
+ } ) ;
691
+ res . end ( null , null , function ( ) {
692
+ callbacks ++
693
+ } ) ;
694
+ } )
695
+
696
+ request ( server )
697
+ . get ( '/' )
698
+ . set ( 'Accept-Encoding' , 'gzip' )
699
+ . expect ( 'Content-Encoding' , 'gzip' )
700
+ . end ( function ( ) {
701
+ assert . equal ( callbacks , 3 )
702
+ done ( ) ;
703
+ } ) ;
704
+ } )
705
+ } )
677
706
} )
678
707
679
708
function createServer ( opts , fn ) {
You can’t perform that action at this time.
0 commit comments