Skip to content

Commit ce1e0c3

Browse files
committed
Updates tests for depthFactor fix
1 parent adf28ba commit ce1e0c3

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

src/Node/tests/index.test.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,6 @@ describe('<Node />', () => {
143143
});
144144

145145

146-
it('mutates the node\'s `y` property according to `depthFactor`, when specified', () => {
147-
const depthFactor = 100;
148-
const expectedY = nodeData.depth * depthFactor;
149-
const renderedComponent = shallow(
150-
<Node
151-
{...mockProps}
152-
orientation="vertical"
153-
depthFactor={depthFactor}
154-
/>
155-
);
156-
157-
expect(renderedComponent.prop('transform')).toBe(`translate(${nodeData.parent.x},${expectedY})`);
158-
});
159-
160-
161146
it('applies its own x/y coords on `transform` once mounted', () => {
162147
const fixture = `translate(${nodeData.y},${nodeData.x})`;
163148
const renderedComponent = mount(

src/Tree/tests/index.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,24 @@ describe('<Tree />', () => {
130130
});
131131

132132

133+
it('mutates each node\'s `y` prop according to `depthFactor` when specified', () => {
134+
const depthFactor = 100;
135+
// const expectedY = nodeData.depth * depthFactor;
136+
const renderedComponent = shallow(
137+
<Tree
138+
data={mockData}
139+
orientation="vertical"
140+
depthFactor={depthFactor}
141+
/>
142+
);
143+
144+
const { nodes } = renderedComponent.instance().generateTree(mockData);
145+
nodes.forEach((node) => {
146+
expect(node.y).toBe(node.depth * depthFactor);
147+
});
148+
});
149+
150+
133151
it('passes `props.orientation` to its <Node /> and <Link /> children', () => {
134152
const fixture = 'vertical';
135153
const renderedComponent = shallow(

0 commit comments

Comments
 (0)