From d6376c31e0522e3313a475c3def7c4f96141ef2b Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Wed, 6 Jan 2021 13:12:24 +0000 Subject: [PATCH] Test: ensure toBuffer tests return any errors --- test/unit/toBuffer.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/test/unit/toBuffer.js b/test/unit/toBuffer.js index 3759f524..8c9da6ef 100644 --- a/test/unit/toBuffer.js +++ b/test/unit/toBuffer.js @@ -6,22 +6,19 @@ const sharp = require('../../'); const fixtures = require('../fixtures'); describe('toBuffer', () => { - it('reusing same sharp object does not reset previously passed parameters to toBuffer', (done) => { + it('reusing same sharp object does not reset previously passed parameters to toBuffer', async () => { const image = sharp(fixtures.inputJpg); - image.toBuffer({ resolveWithObject: true }).then((obj) => { - image.toBuffer().then((buff) => { - assert.strictEqual(Buffer.isBuffer(buff), true); - assert.strictEqual(typeof obj, 'object'); - done(); - }); - }); + const obj = await image.toBuffer({ resolveWithObject: true }); + assert.strictEqual(typeof obj, 'object'); + assert.strictEqual(typeof obj.info, 'object'); + assert.strictEqual(Buffer.isBuffer(obj.data), true); + const data = await image.toBuffer(); + assert.strictEqual(Buffer.isBuffer(data), true); }); - it('correctly process animated webp with height > 16383', (done) => { - const image = sharp(fixtures.inputWebPAnimatedBigHeight, { animated: true }); - image.toBuffer().then((buff) => { - assert.strictEqual(Buffer.isBuffer(buff), true); - done(); - }); + it('correctly process animated webp with height > 16383', async () => { + const data = await sharp(fixtures.inputWebPAnimatedBigHeight, { animated: true }) + .toBuffer(); + assert.strictEqual(Buffer.isBuffer(data), true); }); });