test: allow for rounding errors

This commit is contained in:
Martin Stamm 2022-05-20 18:13:19 +02:00 committed by fake-join[bot]
parent 9b8c190625
commit 7838a1bd67
2 changed files with 11 additions and 13 deletions

View File

@ -405,10 +405,8 @@ describe('behavior - LabelBehavior', function() {
]); ]);
// then // then
expect({ expect(sequenceFlowConnection.label.x).to.be.closeTo(273, 1);
x: sequenceFlowConnection.label.x, expect(sequenceFlowConnection.label.y).to.be.closeTo(178, 1);
y: sequenceFlowConnection.label.y
}).to.eql({ x: 273, y: 178 });
} }
)); ));

View File

@ -48,7 +48,7 @@ describe('behavior - LayoutConnectionBehavior', function() {
modeling.updateWaypoints(sequenceFlow, newWaypoints, hints); modeling.updateWaypoints(sequenceFlow, newWaypoints, hints);
// then // then
expectWaypoints(association, [ expectApproximateWaypoints(association, [
{ x: 525, y: 110 }, { x: 525, y: 110 },
{ x: 355, y: 229 }, { x: 355, y: 229 },
]); ]);
@ -66,7 +66,7 @@ describe('behavior - LayoutConnectionBehavior', function() {
modeling.moveElements([ startEvent, endEvent ], { x: 0, y: 200 }); modeling.moveElements([ startEvent, endEvent ], { x: 0, y: 200 });
// then // then
expectWaypoints(association, [ expectApproximateWaypoints(association, [
{ x: 525, y: 110 }, { x: 525, y: 110 },
{ x: 460, y: 350 }, { x: 460, y: 350 },
]); ]);
@ -90,7 +90,7 @@ describe('behavior - LayoutConnectionBehavior', function() {
modeling.updateWaypoints(sequenceFlow, newWaypoints); modeling.updateWaypoints(sequenceFlow, newWaypoints);
// then // then
expectWaypoints(association, [ expectApproximateWaypoints(association, [
{ x: 525, y: 110 }, { x: 525, y: 110 },
{ x: 460, y: 300 } { x: 460, y: 300 }
]); ]);
@ -123,7 +123,7 @@ describe('behavior - LayoutConnectionBehavior', function() {
modeling.updateWaypoints(sequenceFlow, newWaypoints, hints); modeling.updateWaypoints(sequenceFlow, newWaypoints, hints);
// then // then
expectWaypoints(association, [ expectApproximateWaypoints(association, [
{ x: 355, y: 229 }, { x: 355, y: 229 },
{ x: 525, y: 110 } { x: 525, y: 110 }
]); ]);
@ -141,7 +141,7 @@ describe('behavior - LayoutConnectionBehavior', function() {
modeling.moveElements([ startEvent, endEvent ], { x: 0, y: 200 }); modeling.moveElements([ startEvent, endEvent ], { x: 0, y: 200 });
// then // then
expectWaypoints(association, [ expectApproximateWaypoints(association, [
{ x: 460, y: 350 }, { x: 460, y: 350 },
{ x: 525, y: 110 } { x: 525, y: 110 }
]); ]);
@ -166,7 +166,7 @@ describe('behavior - LayoutConnectionBehavior', function() {
modeling.updateWaypoints(sequenceFlow, newWaypoints); modeling.updateWaypoints(sequenceFlow, newWaypoints);
// then // then
expectWaypoints(association, [ expectApproximateWaypoints(association, [
{ x: 460, y: 300 }, { x: 460, y: 300 },
{ x: 525, y: 110 } { x: 525, y: 110 }
]); ]);
@ -196,7 +196,7 @@ function copyWaypoints(connection) {
}); });
} }
function expectWaypoints(connection, expectedWaypoints) { function expectApproximateWaypoints(connection, expectedWaypoints) {
var actualWaypoints = connection.waypoints; var actualWaypoints = connection.waypoints;
@ -206,7 +206,7 @@ function expectWaypoints(connection, expectedWaypoints) {
expect(connection.waypoints.length).to.eql(expectedWaypoints.length); expect(connection.waypoints.length).to.eql(expectedWaypoints.length);
for (var i in actualWaypoints) { for (var i in actualWaypoints) {
expect(actualWaypoints[i].x).to.eql(expectedWaypoints[i].x); expect(actualWaypoints[i].x).to.be.closeTo(expectedWaypoints[i].x, 1);
expect(actualWaypoints[i].y).to.eql(expectedWaypoints[i].y); expect(actualWaypoints[i].y).to.be.closeTo(expectedWaypoints[i].y, 1);
} }
} }