From 65e61ad001a6a65be090bfbbe2f75b47ae016927 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Thu, 19 Oct 2023 16:08:34 +0100 Subject: [PATCH] Tests: ensure SVG is well-formed, detect lack of pango --- test/unit/composite.js | 2 +- test/unit/svg.js | 6 +++--- test/unit/text.js | 22 ++++++++++++++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/test/unit/composite.js b/test/unit/composite.js index 46528ad2..bda9d844 100644 --- a/test/unit/composite.js +++ b/test/unit/composite.js @@ -246,7 +246,7 @@ describe('composite', () => { sharp(fixtures.inputJpg) .resize(300, 300) .composite([{ - input: Buffer.from(''), + input: Buffer.from(''), density: 96, blend: 'dest-in', cutout: true diff --git a/test/unit/svg.js b/test/unit/svg.js index 46c1456c..8f147b0a 100644 --- a/test/unit/svg.js +++ b/test/unit/svg.js @@ -141,21 +141,21 @@ describe('SVG input', function () { it('Fails to render SVG larger than 32767x32767', () => assert.rejects( - () => sharp(Buffer.from('')).toBuffer(), + () => sharp(Buffer.from('')).toBuffer(), /Input SVG image exceeds 32767x32767 pixel limit/ ) ); it('Fails to render scaled SVG larger than 32767x32767', () => assert.rejects( - () => sharp(Buffer.from('')).resize(32768).toBuffer(), + () => sharp(Buffer.from('')).resize(32768).toBuffer(), /Input SVG image will exceed 32767x32767 pixel limit when scaled/ ) ); it('Detects SVG passed as a string', () => assert.rejects( - () => sharp('').toBuffer(), + () => sharp('').toBuffer(), /Input file is missing, did you mean/ ) ); diff --git a/test/unit/text.js b/test/unit/text.js index 742d039a..e37fafc7 100644 --- a/test/unit/text.js +++ b/test/unit/text.js @@ -11,13 +11,16 @@ const fixtures = require('../fixtures'); describe('Text to image', function () { this.retries(3); - it('text with default values', async () => { + it('text with default values', async function () { const output = fixtures.path('output.text-default.png'); const text = sharp({ text: { text: 'Hello, world !' } }); + if (!sharp.versions.pango) { + return this.skip(); + } const info = await text.png().toFile(output); assert.strictEqual('png', info.format); assert.strictEqual(3, info.channels); @@ -49,6 +52,9 @@ describe('Text to image', function () { height: maxHeight } }); + if (!sharp.versions.pango) { + return this.skip(); + } text.toFile(output, function (err, info) { if (err) throw err; assert.strictEqual('png', info.format); @@ -69,6 +75,9 @@ describe('Text to image', function () { dpi } }); + if (!sharp.versions.pango) { + return this.skip(); + } text.toFile(output, function (err, info) { if (err) throw err; assert.strictEqual('png', info.format); @@ -90,6 +99,9 @@ describe('Text to image', function () { dpi } }); + if (!sharp.versions.pango) { + return this.skip(); + } text.toFile(output, function (err, info) { if (err) throw err; assert.strictEqual('png', info.format); @@ -112,6 +124,9 @@ describe('Text to image', function () { font: 'sans 100' } }); + if (!sharp.versions.pango) { + return this.skip(); + } text.toFile(output, function (err, info) { if (err) throw err; assert.strictEqual('png', info.format); @@ -122,7 +137,7 @@ describe('Text to image', function () { }); }); - it('text with justify and composite', done => { + it('text with justify and composite', function (done) { const output = fixtures.path('output.text-composite.png'); const width = 500; const dpi = 300; @@ -153,6 +168,9 @@ describe('Text to image', function () { left: 30, top: 250 }]); + if (!sharp.versions.pango) { + return this.skip(); + } text.toFile(output, function (err, info) { if (err) throw err; assert.strictEqual('png', info.format);