@@ -47,6 +47,10 @@ describe('Computed chart dimensions', () => {
4747 top : 10 ,
4848 bottom : 10 ,
4949 } ;
50+ const legendSize = {
51+ top : 0 ,
52+ left : 0 ,
53+ } ;
5054
5155 const axis1Dims : AxisTicksDimensions = {
5256 tickValues : [ 0 , 1 ] ,
@@ -89,7 +93,14 @@ describe('Computed chart dimensions', () => {
8993 const axisDims = new Map < AxisId , AxisTicksDimensions > ( ) ;
9094 const axisStyles = new Map ( ) ;
9195 const axisSpecs : AxisSpec [ ] = [ ] ;
92- const { chartDimensions } = computeChartDimensions ( parentDim , chartTheme , axisDims , axisStyles , axisSpecs ) ;
96+ const { chartDimensions } = computeChartDimensions (
97+ parentDim ,
98+ chartTheme ,
99+ axisDims ,
100+ axisStyles ,
101+ axisSpecs ,
102+ legendSize ,
103+ ) ;
93104 expect ( chartDimensions . left + chartDimensions . width ) . toBeLessThanOrEqual ( parentDim . width ) ;
94105 expect ( chartDimensions . top + chartDimensions . height ) . toBeLessThanOrEqual ( parentDim . height ) ;
95106 expect ( chartDimensions ) . toMatchSnapshot ( ) ;
@@ -101,7 +112,14 @@ describe('Computed chart dimensions', () => {
101112 const axisStyles = new Map ( ) ;
102113 const axisSpecs = [ axisLeftSpec ] ;
103114 axisDims . set ( 'axis_1' , axis1Dims ) ;
104- const { chartDimensions } = computeChartDimensions ( parentDim , chartTheme , axisDims , axisStyles , axisSpecs ) ;
115+ const { chartDimensions } = computeChartDimensions (
116+ parentDim ,
117+ chartTheme ,
118+ axisDims ,
119+ axisStyles ,
120+ axisSpecs ,
121+ legendSize ,
122+ ) ;
105123 expect ( chartDimensions . left + chartDimensions . width ) . toBeLessThanOrEqual ( parentDim . width ) ;
106124 expect ( chartDimensions . top + chartDimensions . height ) . toBeLessThanOrEqual ( parentDim . height ) ;
107125 expect ( chartDimensions ) . toMatchSnapshot ( ) ;
@@ -113,7 +131,14 @@ describe('Computed chart dimensions', () => {
113131 const axisStyles = new Map ( ) ;
114132 const axisSpecs = [ { ...axisLeftSpec , position : Position . Right } ] ;
115133 axisDims . set ( 'axis_1' , axis1Dims ) ;
116- const { chartDimensions } = computeChartDimensions ( parentDim , chartTheme , axisDims , axisStyles , axisSpecs ) ;
134+ const { chartDimensions } = computeChartDimensions (
135+ parentDim ,
136+ chartTheme ,
137+ axisDims ,
138+ axisStyles ,
139+ axisSpecs ,
140+ legendSize ,
141+ ) ;
117142 expect ( chartDimensions . left + chartDimensions . width ) . toBeLessThanOrEqual ( parentDim . width ) ;
118143 expect ( chartDimensions . top + chartDimensions . height ) . toBeLessThanOrEqual ( parentDim . height ) ;
119144 expect ( chartDimensions ) . toMatchSnapshot ( ) ;
@@ -130,7 +155,14 @@ describe('Computed chart dimensions', () => {
130155 } ,
131156 ] ;
132157 axisDims . set ( 'axis_1' , axis1Dims ) ;
133- const { chartDimensions } = computeChartDimensions ( parentDim , chartTheme , axisDims , axisStyles , axisSpecs ) ;
158+ const { chartDimensions } = computeChartDimensions (
159+ parentDim ,
160+ chartTheme ,
161+ axisDims ,
162+ axisStyles ,
163+ axisSpecs ,
164+ legendSize ,
165+ ) ;
134166 expect ( chartDimensions . left + chartDimensions . width ) . toBeLessThanOrEqual ( parentDim . width ) ;
135167 expect ( chartDimensions . top + chartDimensions . height ) . toBeLessThanOrEqual ( parentDim . height ) ;
136168 expect ( chartDimensions ) . toMatchSnapshot ( ) ;
@@ -147,7 +179,14 @@ describe('Computed chart dimensions', () => {
147179 } ,
148180 ] ;
149181 axisDims . set ( 'axis_1' , axis1Dims ) ;
150- const { chartDimensions } = computeChartDimensions ( parentDim , chartTheme , axisDims , axisStyles , axisSpecs ) ;
182+ const { chartDimensions } = computeChartDimensions (
183+ parentDim ,
184+ chartTheme ,
185+ axisDims ,
186+ axisStyles ,
187+ axisSpecs ,
188+ legendSize ,
189+ ) ;
151190 expect ( chartDimensions . left + chartDimensions . width ) . toBeLessThanOrEqual ( parentDim . width ) ;
152191 expect ( chartDimensions . top + chartDimensions . height ) . toBeLessThanOrEqual ( parentDim . height ) ;
153192 expect ( chartDimensions ) . toMatchSnapshot ( ) ;
@@ -162,7 +201,7 @@ describe('Computed chart dimensions', () => {
162201 } ,
163202 ] ;
164203 axisDims . set ( 'foo' , axis1Dims ) ;
165- const chartDimensions = computeChartDimensions ( parentDim , chartTheme , axisDims , axisStyles , axisSpecs ) ;
204+ const chartDimensions = computeChartDimensions ( parentDim , chartTheme , axisDims , axisStyles , axisSpecs , legendSize ) ;
166205
167206 const expectedDims = {
168207 chartDimensions : {
@@ -172,6 +211,10 @@ describe('Computed chart dimensions', () => {
172211 top : 20 ,
173212 } ,
174213 leftMargin : 10 ,
214+ offset : {
215+ top : 0 ,
216+ left : 0 ,
217+ } ,
175218 } ;
176219
177220 expect ( chartDimensions ) . toEqual ( expectedDims ) ;
@@ -184,7 +227,14 @@ describe('Computed chart dimensions', () => {
184227 hide : true ,
185228 position : Position . Bottom ,
186229 } ) ;
187- const hiddenAxisChartDimensions = computeChartDimensions ( parentDim , chartTheme , axisDims , axisStyles , axisSpecs ) ;
230+ const hiddenAxisChartDimensions = computeChartDimensions (
231+ parentDim ,
232+ chartTheme ,
233+ axisDims ,
234+ axisStyles ,
235+ axisSpecs ,
236+ legendSize ,
237+ ) ;
188238
189239 expect ( hiddenAxisChartDimensions ) . toEqual ( expectedDims ) ;
190240 } ) ;
0 commit comments