Skip to content

Commit

Permalink
Fix randomly failing tooltip test (chartjs#6061)
Browse files Browse the repository at this point in the history
Use utility to trigger the event in the center of element rather than x/y -based coordinates (its the edge for rectangles)
  • Loading branch information
kurkle authored and janelledement committed Feb 10, 2019
1 parent 9f2e4f3 commit 247a1c8
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions test/specs/core.tooltip.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,20 +732,8 @@ describe('Core.Tooltip', function() {
// Trigger an event over top of the element
var pointIndex = 1;
var datasetIndex = 0;
var meta = chart.getDatasetMeta(datasetIndex);
var point = meta.data[pointIndex];
var node = chart.canvas;
var rect = node.getBoundingClientRect();
var evt = new MouseEvent('mousemove', {
view: window,
bubbles: true,
cancelable: true,
clientX: Math.round(rect.left + point._model.x),
clientY: Math.round(rect.top + point._model.y)
});

// Manually trigger rather than having an async test
node.dispatchEvent(evt);
var point = chart.getDatasetMeta(datasetIndex).data[pointIndex];
jasmine.triggerMouseEvent(chart, 'mousemove', point);

// Check and see if tooltip was displayed
var tooltip = chart.tooltip;
Expand Down

0 comments on commit 247a1c8

Please sign in to comment.