mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
31 lines
830 B
JavaScript
31 lines
830 B
JavaScript
// Copyright 2013 Lovell Fuller and others.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const sharp = require('../../');
|
|
const fixtures = require('../fixtures');
|
|
|
|
describe('toFormat', () => {
|
|
it('accepts upper case characters as format parameter (string)', async () => {
|
|
const data = await sharp(fixtures.inputJpg)
|
|
.resize(8, 8)
|
|
.toFormat('PNG')
|
|
.toBuffer();
|
|
|
|
const { format } = await sharp(data).metadata();
|
|
assert.strictEqual(format, 'png');
|
|
});
|
|
|
|
it('accepts upper case characters as format parameter (object)', async () => {
|
|
const data = await sharp(fixtures.inputJpg)
|
|
.resize(8, 8)
|
|
.toFormat({ id: 'PNG' })
|
|
.toBuffer();
|
|
|
|
const { format } = await sharp(data).metadata();
|
|
assert.strictEqual(format, 'png');
|
|
});
|
|
});
|