@@ -28,10 +28,12 @@ import {
2828import transformProps from '../../src/Timeseries/transformProps' ;
2929import { EchartsTimeseriesChartProps } from '../../src/types' ;
3030
31- // Mock the colorScale function
32- const mockColorScale = jest . fn (
33- ( ) => '#1f77b4' ,
34- ) as Partial < CategoricalColorScale > ;
31+ // Mock the colorScale function to return different colors based on key
32+ const mockColorScale = jest . fn ( ( key : string ) => {
33+ if ( key === 'test-key' ) return '#1f77b4' ; // blue
34+ if ( key === 'series-key' ) return '#ff7f0e' ; // orange
35+ return '#2ca02c' ; // green for any other key
36+ } ) as unknown as CategoricalColorScale ;
3537
3638describe ( 'transformSeries' , ( ) => {
3739 const series = { name : 'test-series' } ;
@@ -45,7 +47,8 @@ describe('transformSeries', () => {
4547
4648 const result = transformSeries ( series , mockColorScale , 'test-key' , opts ) ;
4749
48- expect ( ( result as any ) ?. itemStyle . color ) . toBeDefined ( ) ;
50+ expect ( mockColorScale ) . toHaveBeenCalledWith ( 'test-key' , 1 ) ;
51+ expect ( ( result as any ) ?. itemStyle . color ) . toBe ( '#1f77b4' ) ;
4952 } ) ;
5053
5154 it ( 'should use seriesKey if timeShiftColor is not enabled' , ( ) => {
@@ -57,7 +60,8 @@ describe('transformSeries', () => {
5760
5861 const result = transformSeries ( series , mockColorScale , 'test-key' , opts ) ;
5962
60- expect ( ( result as any ) ?. itemStyle . color ) . toBeDefined ( ) ;
63+ expect ( mockColorScale ) . toHaveBeenCalledWith ( 'series-key' , 2 ) ;
64+ expect ( ( result as any ) ?. itemStyle . color ) . toBe ( '#ff7f0e' ) ;
6165 } ) ;
6266
6367 it ( 'should apply border styles for bar series with connectNulls' , ( ) => {
0 commit comments