node/test/parallel/test-zlib-write-after-flush.js
Rich Trott 6abd8b587e test: remove unused modules
Many tests use require() to import modules that subsequently never gets
used. This removes those imports and, in a few cases, removes other
unused variables from tests.

PR-URL: https://github.com/nodejs/node/pull/4475
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
2016-01-01 16:37:02 -08:00

34 lines
660 B
JavaScript

'use strict';
require('../common');
var assert = require('assert');
var zlib = require('zlib');
var gzip = zlib.createGzip();
var gunz = zlib.createUnzip();
gzip.pipe(gunz);
var output = '';
var input = 'A line of data\n';
gunz.setEncoding('utf8');
gunz.on('data', function(c) {
output += c;
});
process.on('exit', function() {
assert.equal(output, input);
// Make sure that the flush flag was set back to normal
assert.equal(gzip._flushFlag, zlib.Z_NO_FLUSH);
console.log('ok');
});
// make sure that flush/write doesn't trigger an assert failure
gzip.flush(); write();
function write() {
gzip.write(input);
gzip.end();
gunz.read(0);
}