| 1406 | var tooltipPosition = meta.data[slice].tooltipPosition(); |
| 1407 | |
| 1408 | async function recursive(left) { |
| 1409 | chart.config.data.labels[slice] = chart.config.data.labels[slice] + 'XX'; |
| 1410 | chart.update(); |
| 1411 | |
| 1412 | await triggerMouseEvent(chart, 'mouseout', point); |
| 1413 | await triggerMouseEvent(chart, 'mousemove', point); |
| 1414 | var tooltip = chart.tooltip; |
| 1415 | expect(tooltip.dataPoints.length).toBe(1); |
| 1416 | expect(tooltip.x).toBeGreaterThanOrEqual(0); |
| 1417 | if (tooltip.width <= chart.width) { |
| 1418 | expect(tooltip.x + tooltip.width).toBeLessThanOrEqual(chart.width); |
| 1419 | } |
| 1420 | expect(tooltip.caretX).toBeCloseToPixel(tooltipPosition.x); |
| 1421 | // if tooltip is longer than chart area then all tests done |
| 1422 | if (left === 0) { |
| 1423 | throw new Error('max iterations reached'); |
| 1424 | } |
| 1425 | if (tooltip.width < chart.width) { |
| 1426 | await recursive(left - 1); |
| 1427 | } |
| 1428 | } |
| 1429 | |
| 1430 | await recursive(count); |
| 1431 | } |