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 @@ -676,6 +676,35 @@ describe('compression()', function () {
676676 . end ( )
677677 } )
678678 } )
679+
680+ describe ( 'when callbacks are used' , function ( ) {
681+ it ( 'should call the passed callbacks' , function ( done ) {
682+ var callbacks = 0 ;
683+ var server = createServer ( { threshold : '1kb' } , function ( req , res ) {
684+ res . setHeader ( 'Content-Type' , 'text/plain' )
685+ res . write ( 'Hello' , null , function ( ) {
686+ callbacks ++
687+ res . flush ( )
688+ } ) ;
689+ res . write ( ' World' , null , function ( ) {
690+ callbacks ++
691+ res . flush ( )
692+ } ) ;
693+ res . end ( null , null , function ( ) {
694+ callbacks ++
695+ } ) ;
696+ } )
697+
698+ request ( server )
699+ . get ( '/' )
700+ . set ( 'Accept-Encoding' , 'gzip' )
701+ . expect ( 'Content-Encoding' , 'gzip' )
702+ . end ( function ( ) {
703+ assert . equal ( callbacks , 3 )
704+ done ( ) ;
705+ } ) ;
706+ } )
707+ } )
679708} )
680709
681710function createServer ( opts , fn ) {
You can’t perform that action at this time.
0 commit comments