@@ -45,7 +45,8 @@ describe("CoreChart: fit-size", () => {
4545 test ( "uses explicit chart height" , ( ) => {
4646 const { rerender } = renderChart ( { highcharts } ) ;
4747
48- expect ( HighchartsReact ) . toHaveBeenCalledWith ( chartOptionsWithHeight ( undefined ) , expect . anything ( ) ) ;
48+ // Default height is used when explicit height is not set.
49+ expect ( HighchartsReact ) . toHaveBeenCalledWith ( chartOptionsWithHeight ( 400 ) , expect . anything ( ) ) ;
4950
5051 rerender ( { highcharts, options : { chart : { height : "20rem" } } } ) ;
5152
@@ -110,20 +111,27 @@ describe("CoreChart: fit-size", () => {
110111 const offset = verticalAxisTitlePlacement === "top" ? 28 : 0 ;
111112 const { rerender } = renderChart ( { highcharts, fitHeight : true , verticalAxisTitlePlacement } ) ;
112113
114+ // Uses default min height of 200px.
113115 await waitFor ( ( ) => {
114- expect ( HighchartsReact ) . toHaveBeenCalledWith ( chartOptionsWithHeight ( 80 - offset ) , expect . anything ( ) ) ;
116+ expect ( HighchartsReact ) . toHaveBeenCalledWith ( chartOptionsWithHeight ( 200 - offset ) , expect . anything ( ) ) ;
115117 } ) ;
116118
117- rerender ( { highcharts , fitHeight : true , chartHeight : 300 , verticalAxisTitlePlacement } ) ;
118-
119+ // Uses measured height when it is bigger than explicitly provided min height.
120+ rerender ( { highcharts , fitHeight : true , chartMinHeight : 50 , verticalAxisTitlePlacement } ) ;
119121 await waitFor ( ( ) => {
120122 expect ( HighchartsReact ) . toHaveBeenCalledWith ( chartOptionsWithHeight ( 80 - offset ) , expect . anything ( ) ) ;
121123 } ) ;
122124
123- rerender ( { highcharts, fitHeight : true , chartHeight : 300 , chartMinHeight : 200 , verticalAxisTitlePlacement } ) ;
125+ // Chart height has no effect on charts with fit-height.
126+ rerender ( { highcharts, fitHeight : true , chartMinHeight : 50 , chartHeight : 300 , verticalAxisTitlePlacement } ) ;
127+ await waitFor ( ( ) => {
128+ expect ( HighchartsReact ) . toHaveBeenCalledWith ( chartOptionsWithHeight ( 80 - offset ) , expect . anything ( ) ) ;
129+ } ) ;
124130
131+ // Taking min height which is above the default min height.
132+ rerender ( { highcharts, fitHeight : true , chartHeight : 300 , chartMinHeight : 250 , verticalAxisTitlePlacement } ) ;
125133 await waitFor ( ( ) => {
126- expect ( HighchartsReact ) . toHaveBeenCalledWith ( chartOptionsWithHeight ( 200 - offset ) , expect . anything ( ) ) ;
134+ expect ( HighchartsReact ) . toHaveBeenCalledWith ( chartOptionsWithHeight ( 250 - offset ) , expect . anything ( ) ) ;
127135 } ) ;
128136 } ,
129137 ) ;
0 commit comments