@@ -5,8 +5,8 @@ import { act } from "react";
55import highcharts from "highcharts" ;
66import { vi } from "vitest" ;
77
8- import { CoreChartAPI } from "../../../lib/components/core /interfaces" ;
9- import { renderChart , selectLegendItem } from "./common" ;
8+ import { CoreChartProps } from "../interfaces" ;
9+ import { hoverLegendItem , renderChart , selectLegendItem } from "./common" ;
1010import { HighchartsTestHelper } from "./highcharts-utils" ;
1111
1212const clearHighlightPause = ( ) => new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) ) ;
@@ -32,7 +32,7 @@ describe("CoreChart: API tests", () => {
3232
3333 test ( "passes isApiCall=true to onHighlight when triggered programmatically through API" , ( ) => {
3434 const onHighlight = vi . fn ( ) ;
35- let chartApi : CoreChartAPI | null = null ;
35+ let chartApi : CoreChartProps . ChartAPI | null = null ;
3636
3737 renderChart ( { highcharts, onHighlight, options : { series } , callback : ( api ) => ( chartApi = api ) } ) ;
3838
@@ -55,7 +55,7 @@ describe("CoreChart: API tests", () => {
5555
5656 test ( "passes isApiCall=true to onClearHighlight when triggered programmatically through API" , ( ) => {
5757 const onClearHighlight = vi . fn ( ) ;
58- let chartApi : CoreChartAPI | null = null ;
58+ let chartApi : CoreChartProps . ChartAPI | null = null ;
5959
6060 renderChart ( { highcharts, onClearHighlight, options : { series } , callback : ( api ) => ( chartApi = api ) } ) ;
6161
@@ -74,11 +74,30 @@ describe("CoreChart: API tests", () => {
7474
7575 test ( "passes isApiCall=true to onVisibleItemsChange when triggered programmatically through API" , ( ) => {
7676 const onVisibleItemsChange = vi . fn ( ) ;
77- let chartApi : CoreChartAPI | null = null ;
77+ let chartApi : CoreChartProps . ChartAPI | null = null ;
7878
7979 renderChart ( { highcharts, options : { series } , onVisibleItemsChange, callback : ( api ) => ( chartApi = api ) } ) ;
8080
8181 act ( ( ) => chartApi ! . setItemsVisible ( [ "Line 1" ] ) ) ;
8282 expect ( onVisibleItemsChange ) . toHaveBeenCalledWith ( { items : expect . any ( Array ) , isApiCall : true } ) ;
8383 } ) ;
84+
85+ test ( "calls onLegendHover when hovering over a legend item" , ( ) => {
86+ const onLegendHover = vi . fn ( ) ;
87+ const { wrapper } = renderChart ( { highcharts, options : { series } , onLegendHover } ) ;
88+
89+ hoverLegendItem ( 0 , wrapper ) ;
90+
91+ expect ( onLegendHover ) . toHaveBeenCalledWith (
92+ expect . objectContaining ( {
93+ item : expect . objectContaining ( {
94+ id : "Line 1" ,
95+ name : "Line 1" ,
96+ marker : expect . any ( Object ) ,
97+ visible : expect . any ( Boolean ) ,
98+ highlighted : expect . any ( Boolean ) ,
99+ } ) ,
100+ } ) ,
101+ ) ;
102+ } ) ;
84103} ) ;
0 commit comments