node/test/parallel/test-zlib-flush.js
Rich Trott a7335bd1f0 test,benchmark: use deepStrictEqual()
In preparation for a lint rule that will enforce
assert.deepStrictEqual() over assert.deepEqual(), change tests and
benchmarks accordingly. For tests and benchmarks that are testing or
benchmarking assert.deepEqual() itself, apply a comment to ignore the
upcoming rule.

PR-URL: https://github.com/nodejs/node/pull/6213
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-04-22 14:38:09 -07:00

37 lines
1.0 KiB
JavaScript

'use strict';
var common = require('../common');
var assert = require('assert');
var zlib = require('zlib');
var path = require('path');
var fs = require('fs');
const file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg'));
const chunkSize = 16;
const opts = { level: 0 };
const deflater = zlib.createDeflate(opts);
const chunk = file.slice(0, chunkSize);
const expectedNone = Buffer.from([0x78, 0x01]);
const blkhdr = Buffer.from([0x00, 0x10, 0x00, 0xef, 0xff]);
const adler32 = Buffer.from([0x00, 0x00, 0x00, 0xff, 0xff]);
const expectedFull = Buffer.concat([blkhdr, chunk, adler32]);
let actualNone;
let actualFull;
deflater.write(chunk, function() {
deflater.flush(zlib.Z_NO_FLUSH, function() {
actualNone = deflater.read();
deflater.flush(function() {
var bufs = [], buf;
while (buf = deflater.read())
bufs.push(buf);
actualFull = Buffer.concat(bufs);
});
});
});
process.once('exit', function() {
assert.deepStrictEqual(actualNone, expectedNone);
assert.deepStrictEqual(actualFull, expectedFull);
});