@@ -188,5 +188,61 @@ describe("Graph Helper", () => {
188188 expect ( props . fontSize ) . toEqual ( 6 ) ;
189189 } ) ;
190190 } ) ;
191+ describe ( "when node.size is numeric value" , ( ) => {
192+ test ( "should calculate label offset correctly" , ( ) => {
193+ const props = graphHelper . buildNodeProps (
194+ { ...that . node , fontSize : 1 , size : 100 } ,
195+ that . config ,
196+ undefined ,
197+ undefined ,
198+ undefined ,
199+ 1
200+ ) ;
201+
202+ expect ( props . dx ) . toEqual ( 3.5 ) ;
203+ } ) ;
204+ } ) ;
205+ describe ( "when node.size is object and labelPosition is top" , ( ) => {
206+ test ( "should calculate label offset correctly" , ( ) => {
207+ const props = graphHelper . buildNodeProps (
208+ { ...that . node , fontSize : 1 , size : { height : 100 , width : 100 } , labelPosition : "top" } ,
209+ that . config ,
210+ undefined ,
211+ undefined ,
212+ undefined ,
213+ 1
214+ ) ;
215+
216+ expect ( props . dx ) . toEqual ( 3.5 ) ;
217+ } ) ;
218+ } ) ;
219+ describe ( "when node.size is object and labelPosition is right" , ( ) => {
220+ test ( "should calculate label offset correctly" , ( ) => {
221+ const props = graphHelper . buildNodeProps (
222+ { ...that . node , fontSize : 1 , size : { height : 100 , width : 100 } , labelPosition : "right" } ,
223+ that . config ,
224+ undefined ,
225+ undefined ,
226+ undefined ,
227+ 1
228+ ) ;
229+
230+ expect ( props . dx ) . toEqual ( 3.5 ) ;
231+ } ) ;
232+ } ) ;
233+ describe ( "when node.size is object and labelPosition is center" , ( ) => {
234+ test ( "should calculate label offset correctly" , ( ) => {
235+ const props = graphHelper . buildNodeProps (
236+ { ...that . node , fontSize : 1 , size : { height : 100 , width : 100 } , labelPosition : "center" } ,
237+ that . config ,
238+ undefined ,
239+ undefined ,
240+ undefined ,
241+ 1
242+ ) ;
243+
244+ expect ( props . dx ) . toEqual ( 2.5 ) ;
245+ } ) ;
246+ } ) ;
191247 } ) ;
192248} ) ;
0 commit comments