mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Linter: apply all recommended biome settings
Enforces previously-skipped useArrowFunction check
This commit is contained in:
@@ -10,20 +10,20 @@ const assert = require('node:assert');
|
||||
const sharp = require('../../');
|
||||
const fixtures = require('../fixtures');
|
||||
|
||||
describe('SVG input', function () {
|
||||
it('Convert SVG to PNG at default 72DPI', function (_t, done) {
|
||||
describe('SVG input', () => {
|
||||
it('Convert SVG to PNG at default 72DPI', (_t, done) => {
|
||||
sharp(fixtures.inputSvg)
|
||||
.resize(1024)
|
||||
.extract({ left: 290, top: 760, width: 40, height: 40 })
|
||||
.toFormat('png')
|
||||
.toBuffer(function (err, data, info) {
|
||||
.toBuffer((err, data, info) => {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(40, info.width);
|
||||
assert.strictEqual(40, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('svg72.png'), data, function (err) {
|
||||
fixtures.assertSimilar(fixtures.expected('svg72.png'), data, (err) => {
|
||||
if (err) throw err;
|
||||
sharp(data).metadata(function (err, info) {
|
||||
sharp(data).metadata((err, info) => {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(72, info.density);
|
||||
done();
|
||||
@@ -32,19 +32,19 @@ describe('SVG input', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Convert SVG to PNG at 1200DPI', function (_t, done) {
|
||||
it('Convert SVG to PNG at 1200DPI', (_t, done) => {
|
||||
sharp(fixtures.inputSvg, { density: 1200 })
|
||||
.resize(1024)
|
||||
.extract({ left: 290, top: 760, width: 40, height: 40 })
|
||||
.toFormat('png')
|
||||
.toBuffer(function (err, data, info) {
|
||||
.toBuffer((err, data, info) => {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(40, info.width);
|
||||
assert.strictEqual(40, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('svg1200.png'), data, function (err) {
|
||||
fixtures.assertSimilar(fixtures.expected('svg1200.png'), data, (err) => {
|
||||
if (err) throw err;
|
||||
sharp(data).metadata(function (err, info) {
|
||||
sharp(data).metadata((err, info) => {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(1200, info.density);
|
||||
done();
|
||||
@@ -53,22 +53,22 @@ describe('SVG input', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Convert SVG to PNG at DPI larger than 2400', function (_t, done) {
|
||||
it('Convert SVG to PNG at DPI larger than 2400', (_t, done) => {
|
||||
const size = 1024;
|
||||
sharp(fixtures.inputSvgSmallViewBox).metadata(function (err, metadata) {
|
||||
sharp(fixtures.inputSvgSmallViewBox).metadata((err, metadata) => {
|
||||
if (err) throw err;
|
||||
const density = (size / Math.max(metadata.width, metadata.height)) * metadata.density;
|
||||
sharp(fixtures.inputSvgSmallViewBox, { density })
|
||||
.resize(size)
|
||||
.toFormat('png')
|
||||
.toBuffer(function (err, data, info) {
|
||||
.toBuffer((err, data, info) => {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(size, info.width);
|
||||
assert.strictEqual(size, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('circle.png'), data, function (err) {
|
||||
fixtures.assertSimilar(fixtures.expected('circle.png'), data, (err) => {
|
||||
if (err) throw err;
|
||||
sharp(data).metadata(function (err, info) {
|
||||
sharp(data).metadata((err, info) => {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(9216, info.density);
|
||||
done();
|
||||
@@ -78,19 +78,19 @@ describe('SVG input', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Convert SVG to PNG utilizing scale-on-load', function (_t, done) {
|
||||
it('Convert SVG to PNG utilizing scale-on-load', (_t, done) => {
|
||||
const size = 1024;
|
||||
sharp(fixtures.inputSvgSmallViewBox)
|
||||
.resize(size)
|
||||
.toFormat('png')
|
||||
.toBuffer(function (err, data, info) {
|
||||
.toBuffer((err, data, info) => {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(size, info.width);
|
||||
assert.strictEqual(size, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('circle.png'), data, function (err) {
|
||||
fixtures.assertSimilar(fixtures.expected('circle.png'), data, (err) => {
|
||||
if (err) throw err;
|
||||
sharp(data).metadata(function (err, info) {
|
||||
sharp(data).metadata((err, info) => {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(72, info.density);
|
||||
done();
|
||||
@@ -99,24 +99,24 @@ describe('SVG input', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Convert SVG to PNG at 14.4DPI', function (_t, done) {
|
||||
it('Convert SVG to PNG at 14.4DPI', (_t, done) => {
|
||||
sharp(fixtures.inputSvg, { density: 14.4 })
|
||||
.toFormat('png')
|
||||
.toBuffer(function (err, data, info) {
|
||||
.toBuffer((err, data, info) => {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(20, info.width);
|
||||
assert.strictEqual(20, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('svg14.4.png'), data, function (err) {
|
||||
fixtures.assertSimilar(fixtures.expected('svg14.4.png'), data, (err) => {
|
||||
if (err) throw err;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('Convert SVG with embedded images to PNG, respecting dimensions, autoconvert to PNG', function (_t, done) {
|
||||
it('Convert SVG with embedded images to PNG, respecting dimensions, autoconvert to PNG', (_t, done) => {
|
||||
sharp(fixtures.inputSvgWithEmbeddedImages)
|
||||
.toBuffer(function (err, data, info) {
|
||||
.toBuffer((err, data, info) => {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(480, info.width);
|
||||
|
||||
Reference in New Issue
Block a user