@@ -36,6 +36,7 @@ describe('<Link />', () => {
36
36
jest . spyOn ( Link . prototype , 'drawDiagonalPath' ) ;
37
37
jest . spyOn ( Link . prototype , 'drawElbowPath' ) ;
38
38
jest . spyOn ( Link . prototype , 'drawStraightPath' ) ;
39
+ jest . spyOn ( Link . prototype , 'drawStepPath' ) ;
39
40
jest . spyOn ( Link . prototype , 'applyOpacity' ) ;
40
41
jest . spyOn ( pathFuncs , 'testPathFunc' ) ;
41
42
@@ -70,13 +71,15 @@ describe('<Link />', () => {
70
71
const diagonalComponent = shallow ( < Link { ...mockProps } /> ) ;
71
72
const elbowComponent = shallow ( < Link { ...mockProps } pathFunc = "elbow" /> ) ;
72
73
const straightComponent = shallow ( < Link { ...mockProps } pathFunc = "straight" /> ) ;
74
+ const stepComponent = shallow ( < Link { ...mockProps } pathFunc = "step" /> ) ;
73
75
shallow ( < Link { ...mockProps } pathFunc = { pathFuncs . testPathFunc } /> ) ;
74
76
75
77
expect ( diagonalComponent . instance ( ) . drawDiagonalPath ) . toHaveBeenCalled ( ) ;
76
78
expect ( elbowComponent . instance ( ) . drawElbowPath ) . toHaveBeenCalled ( ) ;
77
79
expect ( straightComponent . instance ( ) . drawStraightPath ) . toHaveBeenCalled ( ) ;
80
+ expect ( stepComponent . instance ( ) . drawStepPath ) . toHaveBeenCalled ( ) ;
78
81
expect ( pathFuncs . testPathFunc ) . toHaveBeenCalled ( ) ;
79
- expect ( Link . prototype . drawPath ) . toHaveBeenCalledTimes ( 4 ) ;
82
+ expect ( Link . prototype . drawPath ) . toHaveBeenCalledTimes ( 5 ) ;
80
83
} ) ;
81
84
82
85
it ( 'returns an appropriate elbowPath according to `props.orientation`' , ( ) => {
@@ -111,6 +114,18 @@ describe('<Link />', () => {
111
114
) ;
112
115
} ) ;
113
116
117
+ it ( 'return an appropriate stepPath according to `props.orientation`' , ( ) => {
118
+ const { source, target } = linkData ;
119
+ const deltaY = target . y - source . y ;
120
+
121
+ expect ( Link . prototype . drawStepPath ( linkData , 'horizontal' ) ) . toBe (
122
+ `M${ source . y } ,${ source . x } H${ source . y + deltaY / 2 } V${ target . x } H${ target . y } ` ,
123
+ ) ;
124
+ expect ( Link . prototype . drawStepPath ( linkData , 'vertical' ) ) . toBe (
125
+ `M${ source . x } ,${ source . y } V${ source . y + deltaY / 2 } H${ target . x } V${ target . y } ` ,
126
+ ) ;
127
+ } ) ;
128
+
114
129
it ( 'fades in once it has been mounted' , ( ) => {
115
130
const fixture = 1 ;
116
131
const renderedComponent = mount ( < Link { ...mockProps } /> ) ;
0 commit comments