@@ -12,28 +12,31 @@ describe('<Node />', () => {
12
12
y : 321 ,
13
13
} ;
14
14
15
+ const mockProps = {
16
+ nodeData,
17
+ orientation : 'horizontal' ,
18
+ transitions : {
19
+ enabled : true ,
20
+ duration : 500 ,
21
+ } ,
22
+ } ;
23
+
15
24
it ( 'has the correct `id` attribute value' , ( ) => {
16
25
const renderedComponent = shallow (
17
- < Node
18
- nodeData = { nodeData }
19
- orientation = "horizontal"
20
- />
26
+ < Node { ...mockProps } />
21
27
) ;
22
28
23
29
expect ( renderedComponent . find ( 'g' ) . prop ( 'id' ) ) . toBe ( nodeData . id ) ;
24
30
} ) ;
25
31
26
32
it ( 'applies correct base className if `nodeData._children` is defined' , ( ) => {
27
33
const noChildrenComponent = shallow (
28
- < Node
29
- nodeData = { nodeData }
30
- orientation = "horizontal"
31
- />
34
+ < Node { ...mockProps } />
32
35
) ;
33
36
const withChildrenComponent = shallow (
34
37
< Node
38
+ { ...mockProps }
35
39
nodeData = { { ...nodeData , _children : [ ] } }
36
- orientation = "horizontal"
37
40
/>
38
41
) ;
39
42
@@ -46,16 +49,15 @@ describe('<Node />', () => {
46
49
const circleStyle = { fill : 'green' } ;
47
50
const noChildrenComponent = shallow (
48
51
< Node
49
- nodeData = { nodeData }
50
- orientation = "horizontal"
52
+ { ...mockProps }
51
53
leafCircleStyle = { leafCircleStyle }
52
54
circleStyle = { circleStyle }
53
55
/>
54
56
) ;
55
57
const withChildrenComponent = shallow (
56
58
< Node
59
+ { ...mockProps }
57
60
nodeData = { { ...nodeData , _children : [ ] } }
58
- orientation = "horizontal"
59
61
leafCircleStyle = { leafCircleStyle }
60
62
circleStyle = { circleStyle }
61
63
/>
@@ -69,14 +71,11 @@ describe('<Node />', () => {
69
71
const horizontalTransform = `translate(${ nodeData . y } ,${ nodeData . x } )` ;
70
72
const verticalTransform = `translate(${ nodeData . x } ,${ nodeData . y } )` ;
71
73
const horizontalComponent = shallow (
72
- < Node
73
- nodeData = { nodeData }
74
- orientation = "horizontal"
75
- />
74
+ < Node { ...mockProps } />
76
75
) ;
77
76
const verticalComponent = shallow (
78
77
< Node
79
- nodeData = { nodeData }
78
+ { ... mockProps }
80
79
orientation = "vertical"
81
80
/>
82
81
) ;
@@ -88,8 +87,7 @@ describe('<Node />', () => {
88
87
it ( 'should take an `onClick` prop' , ( ) => {
89
88
const renderedComponent = shallow (
90
89
< Node
91
- nodeData = { nodeData }
92
- orientation = "horizontal"
90
+ { ...mockProps }
93
91
onClick = { ( ) => { } }
94
92
/>
95
93
) ;
@@ -101,8 +99,7 @@ describe('<Node />', () => {
101
99
const onClickSpy = jest . fn ( ) ;
102
100
const renderedComponent = shallow (
103
101
< Node
104
- nodeData = { nodeData }
105
- orientation = "horizontal"
102
+ { ...mockProps }
106
103
onClick = { onClickSpy }
107
104
/>
108
105
) ;
@@ -115,8 +112,7 @@ describe('<Node />', () => {
115
112
const fixture = { keyA : 'valA' , keyB : 'valB' } ;
116
113
const renderedComponent = shallow (
117
114
< Node
118
- nodeData = { nodeData }
119
- orientation = "horizontal"
115
+ { ...mockProps }
120
116
secondaryLabels = { fixture }
121
117
/>
122
118
) ;
@@ -137,7 +133,7 @@ describe('<Node />', () => {
137
133
const expectedY = nodeData . depth * depthFactor ;
138
134
const renderedComponent = shallow (
139
135
< Node
140
- nodeData = { nodeData }
136
+ { ... mockProps }
141
137
orientation = "vertical"
142
138
depthFactor = { depthFactor }
143
139
/>
0 commit comments