Test: ensure toBuffer tests return any errors

This commit is contained in:
Lovell Fuller 2021-01-06 13:12:24 +00:00
parent a7003e93c8
commit d6376c31e0

View File

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