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); }); });