11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci// Test unzipping a file that was created with a non-node brotli lib, 31cb0ef41Sopenharmony_ci// piped in as fast as possible. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst common = require('../common'); 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ciconst zlib = require('zlib'); 81cb0ef41Sopenharmony_ciconst path = require('path'); 91cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 121cb0ef41Sopenharmony_citmpdir.refresh(); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst decompress = new zlib.BrotliDecompress(); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciconst fs = require('fs'); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciconst fixture = fixtures.path('person.jpg.br'); 191cb0ef41Sopenharmony_ciconst unzippedFixture = fixtures.path('person.jpg'); 201cb0ef41Sopenharmony_ciconst outputFile = path.resolve(tmpdir.path, 'person.jpg'); 211cb0ef41Sopenharmony_ciconst expect = fs.readFileSync(unzippedFixture); 221cb0ef41Sopenharmony_ciconst inp = fs.createReadStream(fixture); 231cb0ef41Sopenharmony_ciconst out = fs.createWriteStream(outputFile); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ciinp.pipe(decompress).pipe(out); 261cb0ef41Sopenharmony_ciout.on('close', common.mustCall(() => { 271cb0ef41Sopenharmony_ci const actual = fs.readFileSync(outputFile); 281cb0ef41Sopenharmony_ci assert.strictEqual(actual.length, expect.length); 291cb0ef41Sopenharmony_ci for (let i = 0, l = actual.length; i < l; i++) { 301cb0ef41Sopenharmony_ci assert.strictEqual(actual[i], expect[i], `byte[${i}]`); 311cb0ef41Sopenharmony_ci } 321cb0ef41Sopenharmony_ci})); 33