From 7ad7193b1e34a14fe036441b4cf859fe219bbec6 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Mon, 30 Mar 2015 11:36:14 +0100 Subject: [PATCH] Add test for progressive JPEG output --- test/unit/io.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/test/unit/io.js b/test/unit/io.js index 811f4b0a..bf4dce0e 100755 --- a/test/unit/io.js +++ b/test/unit/io.js @@ -263,7 +263,34 @@ describe('Input/output', function() { done(); }); - it('Progressive image', function(done) { + it('Progressive JPEG image', function(done) { + sharp(fixtures.inputJpg) + .resize(320, 240) + .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('jpeg', nonProgressiveInfo.format); + assert.strictEqual(320, nonProgressiveInfo.width); + assert.strictEqual(240, nonProgressiveInfo.height); + sharp(fixtures.inputJpg) + .resize(320, 240) + .progressive() + .toBuffer(function(err, progressiveData, progressiveInfo) { + if (err) throw err; + assert.strictEqual(true, progressiveData.length > 0); + assert.strictEqual(progressiveData.length, progressiveInfo.size); + assert.strictEqual(false, progressiveData.length === nonProgressiveData.length); + assert.strictEqual('jpeg', progressiveInfo.format); + assert.strictEqual(320, progressiveInfo.width); + assert.strictEqual(240, progressiveInfo.height); + done(); + }); + }); + }); + + it('Progressive PNG image', function(done) { sharp(fixtures.inputJpg) .resize(320, 240) .png()