Tests: separate IO suite into per-format unit files

This commit is contained in:
Lovell Fuller
2019-01-13 10:11:32 +00:00
parent 98797445de
commit 32a34a8841
7 changed files with 1013 additions and 965 deletions

View File

@@ -6,7 +6,7 @@ const assert = require('assert');
const sharp = require('../../');
const fixtures = require('../fixtures');
describe('PNG output', function () {
describe('PNG', function () {
it('compression level is valid', function () {
assert.doesNotThrow(function () {
sharp().png({ compressionLevel: 0 });
@@ -77,6 +77,32 @@ describe('PNG output', function () {
});
});
it('Progressive PNG image', function (done) {
sharp(fixtures.inputJpg)
.resize(320, 240)
.png({ progressive: false })
.toBuffer(function (err, nonProgressiveData, nonProgressiveInfo) {
if (err) throw err;
assert.strictEqual(true, nonProgressiveData.length > 0);
assert.strictEqual(nonProgressiveData.length, nonProgressiveInfo.size);
assert.strictEqual('png', nonProgressiveInfo.format);
assert.strictEqual(320, nonProgressiveInfo.width);
assert.strictEqual(240, nonProgressiveInfo.height);
sharp(nonProgressiveData)
.png({ progressive: true })
.toBuffer(function (err, progressiveData, progressiveInfo) {
if (err) throw err;
assert.strictEqual(true, progressiveData.length > 0);
assert.strictEqual(progressiveData.length, progressiveInfo.size);
assert.strictEqual(true, progressiveData.length > nonProgressiveData.length);
assert.strictEqual('png', progressiveInfo.format);
assert.strictEqual(320, progressiveInfo.width);
assert.strictEqual(240, progressiveInfo.height);
done();
});
});
});
it('Valid PNG libimagequant palette value does not throw error', function () {
assert.doesNotThrow(function () {
sharp().png({ palette: false });