@@ -85,16 +85,6 @@ describe('format', () => {
8585 expect ( result ( ) ) . toEqual ( [ 20 , 30 ] ) ;
8686 } ) ;
8787
88- test ( 'should handle object value with width and height' , ( ) => {
89- const result = formatSizeFn < NodeData > ( { width : 40 , height : 50 } , 10 ) ;
90- expect ( result ( ) ) . toEqual ( [ 40 , 50 ] ) ;
91- } ) ;
92-
93- test ( 'should handle object value when resultIsNumber is false' , ( ) => {
94- const result = formatSizeFn < NodeData > ( { width : 40 , height : 50 } , 10 ) ;
95- expect ( result ( ) ) . toEqual ( [ 40 , 50 ] ) ;
96- } ) ;
97-
9888 test ( 'should return default value when value is undefined and no node provided' , ( ) => {
9989 const result = formatSizeFn < NodeData > ( undefined , 10 ) ;
10090 expect ( result ( ) ) . toBe ( 10 ) ;
@@ -111,7 +101,7 @@ describe('format', () => {
111101
112102 test ( 'should handle number zero as valid size' , ( ) => {
113103 const result = formatSizeFn < NodeData > ( 0 , 10 ) ;
114- expect ( result ( ) ) . toBe ( 10 ) ; // 0 is falsy, falls back to default
104+ expect ( result ( ) ) . toBe ( 0 ) ;
115105 } ) ;
116106
117107 test ( 'should return default value when data has no size' , ( ) => {
@@ -157,41 +147,45 @@ describe('format', () => {
157147 describe ( 'formatNodeSizeFn' , ( ) => {
158148 test ( 'should return node size plus spacing' , ( ) => {
159149 const result = formatNodeSizeFn ( 20 , 5 , 10 ) ;
160- expect ( result ( ) ) . toBe ( 25 ) ;
150+ expect ( result ( ) ) . toEqual ( [ 25 , 25 , 25 ] ) ;
161151 } ) ;
162152
163153 test ( 'should use default node size when nodeSize is undefined' , ( ) => {
164154 const result = formatNodeSizeFn ( undefined , 5 , 15 ) ;
165- expect ( result ( ) ) . toBe ( 20 ) ; // 15 + 5
155+ expect ( result ( ) ) . toEqual ( [ 20 , 20 , 20 ] ) ; // 15 + 5
166156 } ) ;
167157
168158 test ( 'should handle zero spacing' , ( ) => {
169159 const result = formatNodeSizeFn ( 20 , 0 , 10 ) ;
170- expect ( result ( ) ) . toBe ( 20 ) ;
160+ expect ( result ( ) ) . toEqual ( [ 20 , 20 , 20 ] ) ;
171161 } ) ;
172162
173163 test ( 'should handle undefined spacing' , ( ) => {
174164 const result = formatNodeSizeFn ( 20 , undefined , 10 ) ;
175- expect ( result ( ) ) . toBe ( 20 ) ;
165+ expect ( result ( ) ) . toEqual ( [ 20 , 20 , 20 ] ) ;
176166 } ) ;
177167
178168 test ( 'should handle nodeSize as array' , ( ) => {
179169 const result = formatNodeSizeFn ( [ 30 , 40 ] , 5 , 10 ) ;
180- expect ( result ( ) ) . toBe ( 45 ) ; // max(30, 40) + 5
170+ expect ( result ( ) ) . toEqual ( [ 35 , 45 , 35 ] ) ;
181171 } ) ;
182172
183173 test ( 'should handle nodeSize as function' , ( ) => {
184174 const sizeFn = ( node ?: NodeData ) =>
185175 ( ( node ?. data as any ) ?. customSize as number ) || 25 ;
186176 const result = formatNodeSizeFn ( sizeFn , 10 , 10 ) ;
187- expect ( result ( { id : 'test' , data : { customSize : 30 } } ) ) . toBe ( 40 ) ; // 30 + 10
177+ expect ( result ( { id : 'test' , data : { customSize : 30 } } ) ) . toEqual ( [
178+ 40 , 40 , 40 ,
179+ ] ) ;
188180 } ) ;
189181
190182 test ( 'should handle nodeSpacing as function' , ( ) => {
191183 const spacingFn = ( node ?: NodeData ) =>
192184 ( ( node ?. data as any ) ?. spacing as number ) || 0 ;
193185 const result = formatNodeSizeFn ( 20 , spacingFn , 10 ) ;
194- expect ( result ( { id : 'test' , data : { spacing : 5 } } ) ) . toBe ( 25 ) ; // 20 + 5
186+ expect ( result ( { id : 'test' , data : { spacing : 5 } } ) ) . toEqual ( [
187+ 25 , 25 , 25 ,
188+ ] ) ;
195189 } ) ;
196190
197191 test ( 'should handle both nodeSize and nodeSpacing as functions' , ( ) => {
@@ -200,7 +194,9 @@ describe('format', () => {
200194 const spacingFn = ( node ?: NodeData ) =>
201195 ( ( node ?. data as any ) ?. spacing as number ) || 0 ;
202196 const result = formatNodeSizeFn ( sizeFn , spacingFn , 10 ) ;
203- expect ( result ( { id : 'test' , data : { size : 30 , spacing : 5 } } ) ) . toBe ( 35 ) ;
197+ expect ( result ( { id : 'test' , data : { size : 30 , spacing : 5 } } ) ) . toEqual ( [
198+ 35 , 35 , 35 ,
199+ ] ) ;
204200 } ) ;
205201
206202 test ( 'should return default when nodeSize undefined and node has no size in data' , ( ) => {
@@ -209,32 +205,34 @@ describe('format', () => {
209205 id : 'node1' ,
210206 data : { } ,
211207 } ;
212- expect ( result ( nodeData ) ) . toBe ( 15 ) ; // default 10 + 5 spacing
208+ expect ( result ( nodeData ) ) . toEqual ( [ 15 , 15 , 15 ] ) ; // default 10 + 5 spacing
213209 } ) ;
214210
215211 test ( 'should handle negative spacing' , ( ) => {
216212 const result = formatNodeSizeFn ( 20 , - 5 , 10 ) ;
217- expect ( result ( ) ) . toBe ( 15 ) ; // 20 + (-5)
213+ expect ( result ( ) ) . toEqual ( [ 15 , 15 , 15 ] ) ; // 20 + (-5)
218214 } ) ;
219215
220216 test ( 'should handle fractional sizes and spacing' , ( ) => {
221217 const result = formatNodeSizeFn ( 20.5 , 3.2 , 10 ) ;
222- expect ( result ( ) ) . toBeCloseTo ( 23.7 ) ;
218+ expect ( result ( ) [ 0 ] ) . toBeCloseTo ( 23.7 ) ;
219+ expect ( result ( ) [ 1 ] ) . toBeCloseTo ( 23.7 ) ;
220+ expect ( result ( ) [ 2 ] ) . toBeCloseTo ( 23.7 ) ;
223221 } ) ;
224222
225223 test ( 'should handle number zero node size' , ( ) => {
226224 const result = formatNodeSizeFn ( 0 , 5 , 10 ) ;
227- expect ( result ( ) ) . toBe ( 15 ) ; // 0 is falsy, falls back to default 10 + 5
225+ expect ( result ( ) ) . toEqual ( [ 5 , 5 , 5 ] ) ;
228226 } ) ;
229227
230228 test ( 'should handle large sizes' , ( ) => {
231229 const result = formatNodeSizeFn ( 1000 , 100 , 10 ) ;
232- expect ( result ( ) ) . toBe ( 1100 ) ;
230+ expect ( result ( ) ) . toEqual ( [ 1100 , 1100 , 1100 ] ) ;
233231 } ) ;
234232
235233 test ( 'should use default when all values are undefined' , ( ) => {
236234 const result = formatNodeSizeFn ( undefined , undefined , 12 ) ;
237- expect ( result ( ) ) . toBe ( 12 ) ;
235+ expect ( result ( ) ) . toEqual ( [ 12 , 12 , 12 ] ) ;
238236 } ) ;
239237
240238 test ( 'should handle node data without spacing function' , ( ) => {
@@ -243,12 +241,12 @@ describe('format', () => {
243241 id : 'node1' ,
244242 data : { } ,
245243 } ;
246- expect ( result ( nodeData ) ) . toBe ( 25 ) ;
244+ expect ( result ( nodeData ) ) . toEqual ( [ 25 , 25 , 25 ] ) ;
247245 } ) ;
248246
249247 test ( 'should handle single element array size' , ( ) => {
250248 const result = formatNodeSizeFn ( [ 35 ] , 5 , 10 ) ;
251- expect ( result ( ) ) . toBe ( 40 ) ; // max(35) + 5
249+ expect ( result ( ) ) . toEqual ( [ 40 , 40 , 40 ] ) ; // max(35) + 5
252250 } ) ;
253251 } ) ;
254252} ) ;
0 commit comments