MCPcopy Create free account
hub / github.com/chartjs/Chart.js / testSlice

Function testSlice

test/specs/plugin.tooltip.spec.js:1403–1431  ·  view source on GitHub ↗
(slice, count)

Source from the content-addressed store, hash-verified

1401 });
1402
1403 async function testSlice(slice, count) {
1404 var meta = chart.getDatasetMeta(0);
1405 var point = meta.data[slice].getCenterPoint();
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 }
1432
1433 // Trigger an event over top of the slice
1434 for (var slice = 0; slice < 2; slice++) {

Callers 1

Calls 4

recursiveFunction · 0.85
getDatasetMetaMethod · 0.80
getCenterPointMethod · 0.65
tooltipPositionMethod · 0.45

Tested by

no test coverage detected