mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Tests: separate IO suite into per-format unit files
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user