Files
Lovell Fuller 7e9b350e22 Modernise all unit tests
- Ensure all tests have an expected assertion count
- Ensure all tests have at least one assertion
- Use async/await unless test is callback-specific
2026-05-20 21:57:40 +01:00

30 lines
995 B
JavaScript

/*!
Copyright 2013 Lovell Fuller and others.
SPDX-License-Identifier: Apache-2.0
*/
const { suite, test } = require('node:test');
const sharp = require('../../');
const fixtures = require('../fixtures');
suite('toBuffer', () => {
test('reusing same sharp object does not reset previously passed parameters to toBuffer', async (t) => {
t.plan(4);
const image = sharp(fixtures.inputJpg);
const obj = await image.toBuffer({ resolveWithObject: true });
t.assert.strictEqual(typeof obj, 'object');
t.assert.strictEqual(typeof obj.info, 'object');
t.assert.strictEqual(Buffer.isBuffer(obj.data), true);
const data = await image.toBuffer();
t.assert.strictEqual(Buffer.isBuffer(data), true);
});
test('correctly process animated webp with height > 16383', async (t) => {
t.plan(1);
const data = await sharp(fixtures.inputWebPAnimatedBigHeight, { animated: true })
.toBuffer();
t.assert.strictEqual(Buffer.isBuffer(data), true);
});
});