refactor(nodes): rename computed to measured, add helpers
This commit is contained in:
@@ -15,8 +15,7 @@ const initialNodes: Node[] = nodes.map((n) => ({
|
||||
|
||||
const expectedNodes: Node[] = initialNodes.map((n) => ({
|
||||
...n,
|
||||
computed: {
|
||||
positionAbsolute: n.position,
|
||||
measured: {
|
||||
...nodeDimensions,
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -48,7 +48,7 @@ describe('<ReactFlow />: onNodesChange', () => {
|
||||
id: '1',
|
||||
item: {
|
||||
...nodes[0],
|
||||
computed: { positionAbsolute: nodes[0].position, width: 200, height: 100 },
|
||||
measured: { width: 200, height: 100 },
|
||||
style: { width: 200, height: 100 },
|
||||
},
|
||||
},
|
||||
|
||||
@@ -136,8 +136,8 @@ describe('applyChanges Testing', () => {
|
||||
];
|
||||
const nextNodes = applyNodeChanges(nodeChanges, nodes);
|
||||
|
||||
expect(nodes[0].computed).to.be.undefined;
|
||||
expect(nextNodes[0].computed).to.be.deep.equal({ width: newWidth, height: newHeight });
|
||||
expect(nodes[0].measured).to.be.undefined;
|
||||
expect(nextNodes[0].measured).to.be.deep.equal({ width: newWidth, height: newHeight });
|
||||
expect(nextNodes[0].width).to.be.undefined;
|
||||
expect(nextNodes[0].height).to.be.undefined;
|
||||
});
|
||||
@@ -153,7 +153,7 @@ describe('applyChanges Testing', () => {
|
||||
const nextNodes = applyNodeChanges(nodeChanges, nodes);
|
||||
|
||||
expect(nextNodes[0].position).to.be.deep.equal(newPosition);
|
||||
expect(nextNodes[0].computed).to.be.deep.equal({ width: newWidth, height: newHeight });
|
||||
expect(nextNodes[0].measured).to.be.deep.equal({ width: newWidth, height: newHeight });
|
||||
});
|
||||
|
||||
it('replaces nodes/edges', () => {
|
||||
|
||||
Reference in New Issue
Block a user