-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
api-chart-auto-fit.spec.ts
37 lines (33 loc) · 1.08 KB
/
api-chart-auto-fit.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
36
37
import { chartAutoFit as render } from '../plots/api/chart-auto-fit';
import { createNodeGCanvas } from './utils/createNodeGCanvas';
import { sleep } from './utils/sleep';
import { kebabCase } from './utils/kebabCase';
import './utils/useSnapshotMatchers';
describe('chart.options.autoFit', () => {
const dir = `${__dirname}/snapshots/api/${kebabCase(render.name)}`;
const canvas = createNodeGCanvas(800, 500);
let chart;
let button;
let fitted;
it('chart({ autoFit: true }) should fit parent container', async () => {
const { finished, ...rest } = render({
canvas,
container: document.createElement('div'),
});
chart = rest.chart;
button = rest.button;
fitted = rest.fitted;
await finished;
await sleep(20);
await expect(canvas).toMatchDOMSnapshot(dir, 'step0');
});
it('chart.forceFit() should fit parent container', async () => {
button.dispatchEvent(new CustomEvent('click'));
await fitted;
await sleep(20);
await expect(canvas).toMatchDOMSnapshot(dir, 'step1');
});
afterAll(() => {
canvas?.destroy();
});
});