mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 21:25:20 +00:00

Use assert.strictEqual instead of assert.equal in tests, manually convert types where necessary. PR-URL: https://github.com/nodejs/node/pull/10698 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
31 lines
978 B
JavaScript
31 lines
978 B
JavaScript
'use strict';
|
|
// test unzipping a file that was created with a non-node gzip lib,
|
|
// piped in as fast as possible.
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const zlib = require('zlib');
|
|
const path = require('path');
|
|
|
|
common.refreshTmpDir();
|
|
|
|
const gunzip = zlib.createGunzip();
|
|
|
|
const fs = require('fs');
|
|
|
|
const fixture = path.resolve(common.fixturesDir, 'person.jpg.gz');
|
|
const unzippedFixture = path.resolve(common.fixturesDir, 'person.jpg');
|
|
const outputFile = path.resolve(common.tmpDir, 'person.jpg');
|
|
const expect = fs.readFileSync(unzippedFixture);
|
|
const inp = fs.createReadStream(fixture);
|
|
const out = fs.createWriteStream(outputFile);
|
|
|
|
inp.pipe(gunzip).pipe(out);
|
|
out.on('close', function() {
|
|
const actual = fs.readFileSync(outputFile);
|
|
assert.strictEqual(actual.length, expect.length, 'length should match');
|
|
for (let i = 0, l = actual.length; i < l; i++) {
|
|
assert.strictEqual(actual[i], expect[i], 'byte[' + i + ']');
|
|
}
|
|
});
|