forked from antvis/G2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec-static.spec.ts
35 lines (34 loc) · 1.1 KB
/
spec-static.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Canvas } from '@antv/g';
import * as chartTests from '../plots/static';
import { renderSpec } from './utils/renderSpec';
import { filterTests } from './utils/filterTests';
import './utils/useSnapshotMatchers';
import './utils/useCustomFetch';
import { disableAnimation } from './utils/preprocess';
import { sleep } from './utils/sleep';
import { compose } from './utils/compose';
describe('Charts', () => {
const tests = filterTests(chartTests);
for (const [name, generateOptions] of tests) {
let gCanvas: Canvas;
it(`[Canvas]: ${name}`, async () => {
try {
// @ts-ignore
const { before, after } = generateOptions;
// @ts-ignore
generateOptions.preprocess = compose([disableAnimation]);
before?.();
gCanvas = await renderSpec(generateOptions);
after?.();
const dir = `${__dirname}/snapshots/static`;
await expect(gCanvas).toMatchDOMSnapshot(dir, name, {
fileFormat: 'svg',
keepSVGElementId: false,
});
} finally {
gCanvas?.destroy();
await sleep(50);
}
});
}
});