From 9ddc817a09e1a9681afea6da5a0c808e4e3eda01 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Thu, 21 Jul 2016 15:55:34 +0100 Subject: [PATCH] Add WebP availability check to test added in a5bd68e --- test/unit/resize.js | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/test/unit/resize.js b/test/unit/resize.js index 62bff466..cecfade2 100644 --- a/test/unit/resize.js +++ b/test/unit/resize.js @@ -128,26 +128,28 @@ describe('Resize dimensions', function() { done(); }); - it('WebP shrink-on-load rounds to zero, ensure recalculation is correct', function(done) { - sharp(fixtures.inputJpg) - .resize(1080, 607) - .webp() - .toBuffer(function(err, data, info) { - if (err) throw err; - assert.strictEqual('webp', info.format); - assert.strictEqual(1080, info.width); - assert.strictEqual(607, info.height); - sharp(data) - .resize(233, 131) - .toBuffer(function(err, data, info) { - if (err) throw err; - assert.strictEqual('webp', info.format); - assert.strictEqual(233, info.width); - assert.strictEqual(131, info.height); - done(); - }); - }); - }); + if (sharp.format.webp.output.buffer) { + it('WebP shrink-on-load rounds to zero, ensure recalculation is correct', function(done) { + sharp(fixtures.inputJpg) + .resize(1080, 607) + .webp() + .toBuffer(function(err, data, info) { + if (err) throw err; + assert.strictEqual('webp', info.format); + assert.strictEqual(1080, info.width); + assert.strictEqual(607, info.height); + sharp(data) + .resize(233, 131) + .toBuffer(function(err, data, info) { + if (err) throw err; + assert.strictEqual('webp', info.format); + assert.strictEqual(233, info.width); + assert.strictEqual(131, info.height); + done(); + }); + }); + }); + } if (sharp.format.tiff.input.file) { it('TIFF embed known to cause rounding errors', function(done) {