diff --git a/test/compression.js b/test/compression.js index c54f061a..def7f367 100644 --- a/test/compression.js +++ b/test/compression.js @@ -158,13 +158,15 @@ describe('compression()', function () { it('should back-pressure when compressed', function (done) { var buf var client - var drained = false + var drained = [] var resp var server = createServer({ threshold: 0 }, function (req, res) { resp = res + res.on('drain', function () { - drained = true + drained.push('first') }) + res.setHeader('Content-Type', 'text/plain') res.write('start') pressure() @@ -179,7 +181,11 @@ describe('compression()', function () { function complete () { if (--wait !== 0) return - assert.ok(drained) + assert.deepEqual(drained, [ + 'first', + 'second', + 'true' + ]) done() } @@ -191,9 +197,11 @@ describe('compression()', function () { } resp.on('drain', function () { - resp.write('end') + drained.push('second') + drained.push(String(resp.write('end'))) resp.end() }) + resp.on('finish', complete) client.resume() } @@ -214,13 +222,15 @@ describe('compression()', function () { it('should back-pressure when uncompressed', function (done) { var buf var client - var drained = false + var drained = [] var resp var server = createServer({ filter: function () { return false } }, function (req, res) { resp = res + res.on('drain', function () { - drained = true + drained.push('first') }) + res.setHeader('Content-Type', 'text/plain') res.write('start') pressure() @@ -235,7 +245,11 @@ describe('compression()', function () { function complete () { if (--wait !== 0) return - assert.ok(drained) + assert.deepEqual(drained, [ + 'first', + 'second', + 'true' + ]) done() } @@ -247,7 +261,8 @@ describe('compression()', function () { } resp.on('drain', function () { - resp.write('end') + drained.push('second') + drained.push(String(resp.write('end'))) resp.end() }) resp.on('finish', complete)