-
Notifications
You must be signed in to change notification settings - Fork 0
/
api-chart-on-text-click.spec.ts
32 lines (27 loc) · 1.06 KB
/
api-chart-on-text-click.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
import { chartOnTextClick as render } from '../plots/api/chart-on-text-click';
import { createNodeGCanvas } from './utils/createNodeGCanvas';
import { dispatchFirstElementEvent, createPromise } from './utils/event';
import './utils/useSnapshotMatchers';
import { ChartEvent } from '../../src';
describe('chart.on', () => {
const canvas = createNodeGCanvas(640, 480);
const { finished, chart } = render({ canvas });
chart.off();
it('chart.on("text:click", callback) should provide datum for item element', async () => {
await finished;
const [fired, resolve] = createPromise();
chart.on(`text:${ChartEvent.CLICK}`, resolve);
dispatchFirstElementEvent(canvas, 'click', { detail: 1 });
await fired;
});
it('chart.on("element:click", callback) should provide datum for item element', async () => {
await finished;
const [fired, resolve] = createPromise();
chart.on(`element:${ChartEvent.CLICK}`, resolve);
dispatchFirstElementEvent(canvas, 'click', { detail: 1 });
await fired;
});
afterAll(() => {
canvas?.destroy();
});
});