sharp/test/unit/toBuffer.js
Lovell Fuller f2978651f0 Migrate from mocha to Node.js native test runner
Includes coverage reports when using Node.js 22 onwards
2025-09-21 12:03:27 +01:00

27 lines
987 B
JavaScript

// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
const { describe, it } = require('node:test');
const assert = require('node:assert');
const sharp = require('../../');
const fixtures = require('../fixtures');
describe('toBuffer', () => {
it('reusing same sharp object does not reset previously passed parameters to toBuffer', async () => {
const image = sharp(fixtures.inputJpg);
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', async () => {
const data = await sharp(fixtures.inputWebPAnimatedBigHeight, { animated: true })
.toBuffer();
assert.strictEqual(Buffer.isBuffer(data), true);
});
});