Skip to content

Commit 04fc70f

Browse files
committed
Fix some tests
1 parent 123d53f commit 04fc70f

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

src/Node/tests/index.test.js

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,31 @@ describe('<Node />', () => {
1212
y: 321,
1313
};
1414

15+
const mockProps = {
16+
nodeData,
17+
orientation: 'horizontal',
18+
transitions: {
19+
enabled: true,
20+
duration: 500,
21+
},
22+
};
23+
1524
it('has the correct `id` attribute value', () => {
1625
const renderedComponent = shallow(
17-
<Node
18-
nodeData={nodeData}
19-
orientation="horizontal"
20-
/>
26+
<Node {...mockProps} />
2127
);
2228

2329
expect(renderedComponent.find('g').prop('id')).toBe(nodeData.id);
2430
});
2531

2632
it('applies correct base className if `nodeData._children` is defined', () => {
2733
const noChildrenComponent = shallow(
28-
<Node
29-
nodeData={nodeData}
30-
orientation="horizontal"
31-
/>
34+
<Node {...mockProps} />
3235
);
3336
const withChildrenComponent = shallow(
3437
<Node
38+
{...mockProps}
3539
nodeData={{ ...nodeData, _children: [] }}
36-
orientation="horizontal"
3740
/>
3841
);
3942

@@ -46,16 +49,15 @@ describe('<Node />', () => {
4649
const circleStyle = { fill: 'green' };
4750
const noChildrenComponent = shallow(
4851
<Node
49-
nodeData={nodeData}
50-
orientation="horizontal"
52+
{...mockProps}
5153
leafCircleStyle={leafCircleStyle}
5254
circleStyle={circleStyle}
5355
/>
5456
);
5557
const withChildrenComponent = shallow(
5658
<Node
59+
{...mockProps}
5760
nodeData={{ ...nodeData, _children: [] }}
58-
orientation="horizontal"
5961
leafCircleStyle={leafCircleStyle}
6062
circleStyle={circleStyle}
6163
/>
@@ -69,14 +71,11 @@ describe('<Node />', () => {
6971
const horizontalTransform = `translate(${nodeData.y},${nodeData.x})`;
7072
const verticalTransform = `translate(${nodeData.x},${nodeData.y})`;
7173
const horizontalComponent = shallow(
72-
<Node
73-
nodeData={nodeData}
74-
orientation="horizontal"
75-
/>
74+
<Node {...mockProps} />
7675
);
7776
const verticalComponent = shallow(
7877
<Node
79-
nodeData={nodeData}
78+
{...mockProps}
8079
orientation="vertical"
8180
/>
8281
);
@@ -88,8 +87,7 @@ describe('<Node />', () => {
8887
it('should take an `onClick` prop', () => {
8988
const renderedComponent = shallow(
9089
<Node
91-
nodeData={nodeData}
92-
orientation="horizontal"
90+
{...mockProps}
9391
onClick={() => {}}
9492
/>
9593
);
@@ -101,8 +99,7 @@ describe('<Node />', () => {
10199
const onClickSpy = jest.fn();
102100
const renderedComponent = shallow(
103101
<Node
104-
nodeData={nodeData}
105-
orientation="horizontal"
102+
{...mockProps}
106103
onClick={onClickSpy}
107104
/>
108105
);
@@ -115,8 +112,7 @@ describe('<Node />', () => {
115112
const fixture = { keyA: 'valA', keyB: 'valB' };
116113
const renderedComponent = shallow(
117114
<Node
118-
nodeData={nodeData}
119-
orientation="horizontal"
115+
{...mockProps}
120116
secondaryLabels={fixture}
121117
/>
122118
);
@@ -137,7 +133,7 @@ describe('<Node />', () => {
137133
const expectedY = nodeData.depth * depthFactor;
138134
const renderedComponent = shallow(
139135
<Node
140-
nodeData={nodeData}
136+
{...mockProps}
141137
orientation="vertical"
142138
depthFactor={depthFactor}
143139
/>

0 commit comments

Comments
 (0)