11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci// Regression test for https://github.com/nodejs/node/issues/14523. 41cb0ef41Sopenharmony_ci// Checks that flushes interact properly with writableState.needDrain, 51cb0ef41Sopenharmony_ci// even if no flush callback was passed. 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst common = require('../common'); 81cb0ef41Sopenharmony_ciconst assert = require('assert'); 91cb0ef41Sopenharmony_ciconst zlib = require('zlib'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst zipper = zlib.createGzip({ highWaterMark: 16384 }); 121cb0ef41Sopenharmony_ciconst unzipper = zlib.createGunzip(); 131cb0ef41Sopenharmony_cizipper.pipe(unzipper); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_cizipper.write('A'.repeat(17000)); 161cb0ef41Sopenharmony_cizipper.flush(); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_cilet received = 0; 191cb0ef41Sopenharmony_ciunzipper.on('data', common.mustCallAtLeast((d) => { 201cb0ef41Sopenharmony_ci received += d.length; 211cb0ef41Sopenharmony_ci}, 2)); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci// Properly `.end()`ing the streams would interfere with checking that 241cb0ef41Sopenharmony_ci// `.flush()` works. 251cb0ef41Sopenharmony_ciprocess.on('exit', () => { 261cb0ef41Sopenharmony_ci assert.strictEqual(received, 17000); 271cb0ef41Sopenharmony_ci}); 28