@@ -7,11 +7,12 @@ describe('<Node />', () => {
7
7
const nodeData = {
8
8
id : 'abc123' ,
9
9
name : 'mockNode' ,
10
+ depth : 3 ,
10
11
x : 123 ,
11
12
y : 321 ,
12
13
} ;
13
14
14
- it ( 'should have the correct `id` attribute value' , ( ) => {
15
+ it ( 'has the correct `id` attribute value' , ( ) => {
15
16
const renderedComponent = shallow (
16
17
< Node
17
18
nodeData = { nodeData }
@@ -22,7 +23,7 @@ describe('<Node />', () => {
22
23
expect ( renderedComponent . find ( 'g' ) . prop ( 'id' ) ) . toBe ( nodeData . id ) ;
23
24
} ) ;
24
25
25
- it ( 'should apply correct base className if `nodeData._children` is defined' , ( ) => {
26
+ it ( 'applies correct base className if `nodeData._children` is defined' , ( ) => {
26
27
const noChildrenComponent = shallow (
27
28
< Node
28
29
nodeData = { nodeData }
@@ -40,7 +41,7 @@ describe('<Node />', () => {
40
41
expect ( withChildrenComponent . prop ( 'className' ) ) . toBe ( 'nodeBase' ) ;
41
42
} ) ;
42
43
43
- it ( 'should apply correct <circle> style prop if `nodeData._children` is defined' , ( ) => {
44
+ it ( 'applies correct <circle> style prop if `nodeData._children` is defined' , ( ) => {
44
45
const leafCircleStyle = { fill : 'blue' } ;
45
46
const circleStyle = { fill : 'green' } ;
46
47
const noChildrenComponent = shallow (
@@ -64,7 +65,7 @@ describe('<Node />', () => {
64
65
expect ( withChildrenComponent . find ( 'circle' ) . prop ( 'style' ) ) . toBe ( circleStyle ) ;
65
66
} ) ;
66
67
67
- it ( 'should apply correct `transform` prop, depending on parent `orientation`' , ( ) => {
68
+ it ( 'applies correct `transform` prop, depending on parent `orientation`' , ( ) => {
68
69
const horizontalTransform = `translate(${ nodeData . y } ,${ nodeData . x } )` ;
69
70
const verticalTransform = `translate(${ nodeData . x } ,${ nodeData . y } )` ;
70
71
const horizontalComponent = shallow (
@@ -96,7 +97,7 @@ describe('<Node />', () => {
96
97
expect ( renderedComponent . prop ( 'onClick' ) ) . toBeDefined ( ) ;
97
98
} ) ;
98
99
99
- it ( 'should handle click events and pass the nodeId to onClick handler' , ( ) => {
100
+ it ( 'handles click events and pass the nodeId to onClick handler' , ( ) => {
100
101
const onClickSpy = jest . fn ( ) ;
101
102
const renderedComponent = shallow (
102
103
< Node
@@ -110,7 +111,7 @@ describe('<Node />', () => {
110
111
expect ( onClickSpy ) . toHaveBeenCalledWith ( nodeData . id ) ;
111
112
} ) ;
112
113
113
- it ( 'should map each `props.secondaryLabels` to a <tspan> element' , ( ) => {
114
+ it ( 'maps each `props.secondaryLabels` to a <tspan> element' , ( ) => {
114
115
const fixture = { keyA : 'valA' , keyB : 'valB' } ;
115
116
const renderedComponent = shallow (
116
117
< Node
@@ -130,4 +131,18 @@ describe('<Node />', () => {
130
131
n . text ( ) === `keyB: ${ fixture . keyB } ` ) . length
131
132
) . toBe ( 1 ) ;
132
133
} ) ;
134
+
135
+ it ( 'mutates a node\'s `y` property according to `depthFactor`, when specified' , ( ) => {
136
+ const depthFactor = 100 ;
137
+ const expectedY = nodeData . depth * depthFactor ;
138
+ const renderedComponent = shallow (
139
+ < Node
140
+ nodeData = { nodeData }
141
+ orientation = "vertical"
142
+ depthFactor = { depthFactor }
143
+ />
144
+ ) ;
145
+
146
+ expect ( renderedComponent . prop ( 'transform' ) ) . toBe ( `translate(${ nodeData . x } ,${ expectedY } )` ) ;
147
+ } ) ;
133
148
} ) ;
0 commit comments