Skip to content

Commit

Permalink
test: 补充 event单测
Browse files Browse the repository at this point in the history
  • Loading branch information
xinming committed Feb 8, 2021
1 parent 619585b commit c89805f
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/unit/chart/event/event-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,31 @@ describe('Event', () => {
expect(mousedownEvent).toBeCalled();
});

it('rigger same event twice', async () => {
let plotmousedown = 0;
it('fix: not trigger same event twice', async () => {
let plotClick = 0;
let plotClick2 = 0;
let dblClick = 0;

chart.on('*', (e) => {
if (e.type === 'plot:dblclick') {
plotmousedown += 1;
plotClick += 1;
}
});

chart.on('dblclick', (e) => {
if (e.type === 'plot:dblclick') {
plotClick2 += 1;
}
if (e.type === 'dblclick') {
dblClick += 1;
}
});

simulateMouseEvent(chart.canvas.get('el'), 'dblclick', getClientPoint(chart.canvas, 134, 410));
await delay(500);
expect(plotmousedown).toBe(1);
expect(plotClick).toBe(1);
expect(plotClick2).toBe(0);
expect(dblClick).toBe(1);
});

afterAll(() => {
Expand Down

0 comments on commit c89805f

Please sign in to comment.