Skip to content

Commit d6604e3

Browse files
committed
chore: update screenshot and opt svg with svgo
1 parent abb5a68 commit d6604e3

317 files changed

Lines changed: 52900 additions & 269859 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

__tests__/integration/snapshot.spec.ts

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,68 @@
11
/* eslint-disable no-restricted-syntax */
22
import * as fs from 'fs';
33
import { Canvas, resetEntityCounter } from '@antv/g';
4-
import { format } from 'prettier';
5-
import xmlserializer from 'xmlserializer';
4+
import { serializeToString } from 'xmlserializer';
5+
import { optimize } from 'svgo';
66
import * as tests from './components';
77
import { renderCanvas, sleep } from './canvas';
88
import { fetch } from './fetch';
99

10+
const format = (svg: SVGElement) => {
11+
return optimize(serializeToString(svg as any), {
12+
js2svg: {
13+
pretty: true,
14+
indent: 2,
15+
},
16+
plugins: [
17+
'cleanupIds',
18+
'cleanupAttrs',
19+
'sortAttrs',
20+
'sortDefsChildren',
21+
'removeUselessDefs',
22+
{
23+
name: 'convertPathData',
24+
params: {
25+
floatPrecision: 4,
26+
forceAbsolutePath: true,
27+
28+
applyTransforms: false,
29+
applyTransformsStroked: false,
30+
straightCurves: false,
31+
convertToQ: false,
32+
lineShorthands: false,
33+
convertToZ: false,
34+
curveSmoothShorthands: false,
35+
smartArcRounding: false,
36+
removeUseless: false,
37+
collapseRepeated: false,
38+
utilizeAbsolute: false,
39+
negativeExtraSpace: false,
40+
},
41+
},
42+
{
43+
name: 'convertTransform',
44+
params: {
45+
floatPrecision: 4,
46+
47+
convertToShorts: false,
48+
matrixToTransform: false,
49+
shortTranslate: false,
50+
shortScale: false,
51+
shortRotate: false,
52+
removeUseless: false,
53+
collapseIntoOne: false,
54+
},
55+
},
56+
{
57+
name: 'cleanupNumericValues',
58+
params: {
59+
floatPrecision: 4,
60+
},
61+
},
62+
],
63+
}).data;
64+
};
65+
1066
// @ts-ignore
1167
global.fetch = fetch;
1268

@@ -39,9 +95,7 @@ describe('integration', () => {
3995
const container = canvas.getConfig().container as HTMLElement;
4096
const dom = container.querySelector('svg');
4197

42-
actual = format(xmlserializer.serializeToString(dom as any), {
43-
parser: 'babel',
44-
});
98+
actual = format(dom as SVGElement);
4599

46100
// Remove ';' after format by babel.
47101
if (actual !== 'null') actual = actual.slice(0, -2);

0 commit comments

Comments
 (0)