|
3 | 3 |
|
4 | 4 | import { act } from "react"; |
5 | 5 | import highcharts from "highcharts"; |
| 6 | +import { vi } from "vitest"; |
6 | 7 |
|
7 | 8 | import { KeyCode } from "@cloudscape-design/component-toolkit/internal"; |
8 | 9 |
|
9 | | -import { createChartWrapper, renderChart } from "./common"; |
| 10 | +import { createChartWrapper, hoverLegendItem, renderChart } from "./common"; |
10 | 11 | import { HighchartsTestHelper } from "./highcharts-utils"; |
11 | 12 |
|
12 | 13 | import legendTestClasses from "../../../lib/components/internal/components/chart-legend/test-classes/styles.selectors.js"; |
@@ -451,4 +452,23 @@ describe("CoreChart: legend", () => { |
451 | 452 | expect(wrapper.findLegend()!.findItemTooltip()!.findHeader()!.getElement().textContent).toBe("P2"); |
452 | 453 | }); |
453 | 454 | }); |
| 455 | + |
| 456 | + test("calls onLegendItemHighlight when hovering over a legend item", () => { |
| 457 | + const onLegendItemHighlight = vi.fn(); |
| 458 | + const { wrapper } = renderChart({ highcharts, options: { series }, onLegendItemHighlight }); |
| 459 | + |
| 460 | + hoverLegendItem(0, wrapper); |
| 461 | + |
| 462 | + expect(onLegendItemHighlight).toHaveBeenCalledWith( |
| 463 | + expect.objectContaining({ |
| 464 | + item: expect.objectContaining({ |
| 465 | + id: "L1", |
| 466 | + name: "L1", |
| 467 | + marker: expect.any(Object), |
| 468 | + visible: expect.any(Boolean), |
| 469 | + highlighted: expect.any(Boolean), |
| 470 | + }), |
| 471 | + }), |
| 472 | + ); |
| 473 | + }); |
454 | 474 | }); |
0 commit comments