Skip to content

Commit 603eb87

Browse files
committed
Adding tests.
1 parent fae76d4 commit 603eb87

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/compression.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,35 @@ describe('compression()', function(){
674674
.end()
675675
})
676676
})
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+
})
677706
})
678707

679708
function createServer(opts, fn) {

0 commit comments

Comments
 (0)