1
0
mirror of https://github.com/svg/svgo.git synced 2026-01-27 07:02:06 +03:00
Files
svgo/test/plugins/_transforms.test.js
2025-05-04 17:39:44 +01:00

59 lines
1.2 KiB
JavaScript

import { matrixToTransform } from '../../plugins/_transforms.js';
/** @type {import('../../plugins/_transforms.js').TransformParams} */
const params = {
floatPrecision: 3,
transformPrecision: 5,
matrixToTransform: true,
shortTranslate: true,
shortScale: true,
shortRotate: true,
removeUseless: true,
collapseIntoOne: true,
leadingZero: true,
negativeExtraSpace: false,
convertToShorts: true,
};
/**
* Some tests live here instead of in test SVGs because the output
* is longer, so SVGO doesn't actually use it.
*/
describe('should correctly simplify transforms', () => {
it('matrix(0, -1, 99, 0, 0, 0)', () => {
const matrix = {
name: 'matrix',
data: [0, -1, 99, 0, 0, 0],
};
expect(matrixToTransform(matrix, params)).toStrictEqual([
{
name: 'rotate',
data: [-90],
},
{
name: 'scale',
data: [1, 99],
},
]);
});
it('matrix(0, 1, 1, 0, 0, 0)', () => {
const matrix = {
name: 'matrix',
data: [0, 1, 1, 0, 0, 0],
};
expect(matrixToTransform(matrix, params)).toStrictEqual([
{
name: 'rotate',
data: [90],
},
{
name: 'scale',
data: [1, -1],
},
]);
});
});