1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-29 20:21:14 +03:00

Simplify number rendering and fix -0 in path

Ref https://github.com/svg/svgo/issues/1422
This commit is contained in:
Bogdan Chadkin
2021-03-22 14:38:06 +03:00
parent 316a002299
commit 3d4adb6b04
4 changed files with 16 additions and 26 deletions

View File

@ -142,26 +142,24 @@ describe('stringify path data', () => {
).to.equal('M0-1.2.3 4 5-.6 7 .8');
});
it('should configure precision', () => {
const pathData = [
{ command: 'M', args: [0, -1.9876] },
{ command: 'L', args: [0.3, 3.14159265] },
{ command: 'L', args: [-0.3, -3.14159265] },
{ command: 'L', args: [100, 200] },
];
expect(
stringifyPathData({
pathData: [
{ command: 'M', args: [0, -1.9876] },
{ command: 'L', args: [0.3, 3.14159265] },
{ command: 'L', args: [100, 200] },
],
pathData,
precision: 3,
})
).to.equal('M0-1.988.3 3.142 100 200');
).to.equal('M0-1.988.3 3.142-.3-3.142 100 200');
expect(
stringifyPathData({
pathData: [
{ command: 'M', args: [0, -1.9876] },
{ command: 'L', args: [0.3, 3.14159265] },
{ command: 'L', args: [100, 200] },
],
pathData,
precision: 0,
})
).to.equal('M0-2 0 3 100 200');
).to.equal('M0-2 0 3 0-3 100 200');
});
it('allows to avoid spaces after arc flags', () => {
const pathData = [