Skip to content

Commit c4ba4af

Browse files
committed
Adding tests.
1 parent f9c95f9 commit c4ba4af

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/compression.js

+29
Original file line numberDiff line numberDiff 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

681710
function createServer (opts, fn) {

0 commit comments

Comments
 (0)