node/test/parallel/test-zlib-brotli-flush.js
Rich Trott d77754bfc7 test: prepare tests for no-cond-assign ESLint rule
PR-URL: https://github.com/nodejs/node/pull/41614
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2022-01-22 19:38:17 -08:00

28 lines
700 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const zlib = require('zlib');
const fixtures = require('../common/fixtures');
const file = fixtures.readSync('person.jpg');
const chunkSize = 16;
const deflater = new zlib.BrotliCompress();
const chunk = file.slice(0, chunkSize);
const expectedFull = Buffer.from('iweA/9j/4AAQSkZJRgABAQEASA==', 'base64');
let actualFull;
deflater.write(chunk, function() {
deflater.flush(function() {
const bufs = [];
let buf;
while ((buf = deflater.read()) !== null)
bufs.push(buf);
actualFull = Buffer.concat(bufs);
});
});
process.once('exit', function() {
assert.deepStrictEqual(actualFull, expectedFull);
});