forked from antvis/G2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-chart-options.spec.ts
34 lines (30 loc) · 1 KB
/
api-chart-options.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
import { chartOptions as render } from '../plots/api/chart-options';
import { createNodeGCanvas } from './utils/createNodeGCanvas';
import { sleep } from './utils/sleep';
import { kebabCase } from './utils/kebabCase';
import './utils/useSnapshotMatchers';
import './utils/useCustomFetch';
describe('chart.options', () => {
const dir = `${__dirname}/snapshots/api/${kebabCase(render.name)}`;
const canvas = createNodeGCanvas(800, 500);
let chart;
it('chart.options should init', async () => {
const { finished, ...rest } = render({
canvas,
container: document.createElement('div'),
});
chart = rest.chart;
await finished;
await sleep(20);
await expect(canvas).toMatchDOMSnapshot(dir, 'step0');
});
it('chart.options({ width: 480 }) should update chart._options', async () => {
chart.options({ width: 480 });
await chart.render();
await sleep(20);
await expect(canvas).toMatchDOMSnapshot(dir, 'step1');
});
afterAll(() => {
canvas?.destroy();
});
});