Fix tests

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs 2025-03-06 12:24:48 +01:00
parent 11fe608f9a
commit 40f25180ea
5 changed files with 59 additions and 58 deletions

View file

@ -77,9 +77,9 @@ describe("elbow arrow segment move", () => {
expect(arrow.points).toCloselyEqualPoints([
[0, 0],
[110, 0],
[110, 200],
[190, 200],
[107.93, 0],
[107.93, 185.86],
[185.86, 185.86],
]);
mouse.reset();
@ -88,9 +88,9 @@ describe("elbow arrow segment move", () => {
expect(arrow.points).toCloselyEqualPoints([
[0, 0],
[110, 0],
[110, 200],
[190, 200],
[107.93, 0],
[107.93, 185.86],
[185.86, 185.86],
]);
});
@ -200,9 +200,9 @@ describe("elbow arrow routing", () => {
expect(arrow.points).toCloselyEqualPoints([
[0, 0],
[45, 0],
[45, 206.55],
[90, 206.55],
[42.93, 0],
[42.93, 195.7],
[85.86, 195.7],
]);
});
});
@ -254,9 +254,9 @@ describe("elbow arrow ui", () => {
expect(arrow.elbowed).toBe(true);
expect(arrow.points).toCloselyEqualPoints([
[0, 0],
[45, 0],
[45, 200],
[90, 200],
[42.93, 0],
[42.93, 153.48],
[85.86, 153.48],
]);
});
@ -296,9 +296,8 @@ describe("elbow arrow ui", () => {
expect(arrow.points.map((point) => point.map(Math.round))).toEqual([
[0, 0],
[35, 0],
[35, 183],
[96, 183],
[129, 0],
[129, 131],
]);
});

View file

@ -510,13 +510,13 @@ describe("arrow element", () => {
h.state,
)[0] as ExcalidrawElbowArrowElement;
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05);
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.79);
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.07);
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.86);
UI.resize(rectangle, "se", [-200, -150]);
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05);
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.79);
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.07);
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.86);
});
it("flips the fixed point binding on negative resize for group selection", () => {
@ -538,8 +538,8 @@ describe("arrow element", () => {
h.state,
)[0] as ExcalidrawElbowArrowElement;
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05);
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.79);
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.07);
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.86);
UI.resize([rectangle, arrow], "nw", [300, 350]);
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(0);

View file

@ -297,7 +297,7 @@ History {
"focus": "0.00990",
"gap": 5,
},
"height": "0.92900",
"height": "0.92929",
"points": [
[
0,
@ -305,7 +305,7 @@ History {
],
[
"92.92893",
"-0.92900",
"-0.92929",
],
],
"startBinding": {
@ -318,10 +318,10 @@ History {
"inserted": {
"endBinding": {
"elementId": "id171",
"focus": "-0.02052",
"focus": "-0.02075",
"gap": 5,
},
"height": "0.04625",
"height": "0.07074",
"points": [
[
0,
@ -329,12 +329,12 @@ History {
],
[
"92.92893",
"0.04625",
"0.07074",
],
],
"startBinding": {
"elementId": "id170",
"focus": "0.01841",
"focus": "0.01770",
"gap": 5,
},
"width": "92.92893",
@ -413,7 +413,7 @@ History {
"focus": "0.00990",
"gap": 5,
},
"height": "0.92678",
"height": "0.92929",
"points": [
[
0,
@ -421,7 +421,7 @@ History {
],
[
"92.92893",
"-0.92678",
"-0.92929",
],
],
"startBinding": {
@ -431,7 +431,7 @@ History {
},
"width": "92.92893",
"x": "3.53553",
"y": "0.96071",
"y": "0.96033",
},
},
"id175" => Delta {
@ -871,11 +871,11 @@ History {
0,
],
[
90,
"85.85786",
0,
],
],
"width": 90,
"width": "85.85786",
},
},
},
@ -1250,7 +1250,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": "2.98409",
"height": "1.71911",
"id": "id178",
"index": "Zz",
"isDeleted": false,
@ -1265,7 +1265,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
],
[
"92.92893",
"-2.98409",
"1.71911",
],
],
"roughness": 1,
@ -1290,7 +1290,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"version": 11,
"width": "92.92893",
"x": "3.53553",
"y": "4.70319",
"y": 0,
}
`;
@ -1621,7 +1621,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": "2.98409",
"height": "1.71911",
"id": "id181",
"index": "a0",
"isDeleted": false,
@ -1636,7 +1636,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
],
[
"92.92893",
"-2.98409",
"1.71911",
],
],
"roughness": 1,
@ -1661,7 +1661,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"version": 11,
"width": "92.92893",
"x": "3.53553",
"y": "4.70319",
"y": 0,
}
`;
@ -1779,7 +1779,7 @@ History {
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": "22.46459",
"height": "12.86717",
"index": "a0",
"isDeleted": false,
"lastCommittedPoint": null,
@ -1792,8 +1792,8 @@ History {
0,
],
[
"93.46683",
"-22.46459",
"92.92893",
"12.86717",
],
],
"roughness": 1,
@ -1814,9 +1814,9 @@ History {
"strokeStyle": "solid",
"strokeWidth": 2,
"type": "arrow",
"width": "93.46683",
"x": "2.99764",
"y": "35.33176",
"width": "92.92893",
"x": "3.53553",
"y": 0,
},
"inserted": {
"isDeleted": true,
@ -2332,7 +2332,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": "408.02337",
"height": "369.21589",
"id": "id186",
"index": "a2",
"isDeleted": false,
@ -2346,8 +2346,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
0,
],
[
"495.48945",
"-408.02337",
"496.84035",
"-369.21589",
],
],
"roughness": 1,
@ -2366,9 +2366,9 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"type": "arrow",
"updated": 1,
"version": 10,
"width": "495.48945",
"x": "3.53553",
"y": 0,
"width": "496.84035",
"x": "2.18463",
"y": "-38.80748",
}
`;

View file

@ -196,7 +196,7 @@ exports[`move element > rectangles with binding arrow 7`] = `
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": "87.97595",
"height": "94.40997",
"id": "id2",
"index": "a2",
"isDeleted": false,
@ -210,8 +210,8 @@ exports[`move element > rectangles with binding arrow 7`] = `
0,
],
[
"87.46447",
"87.97595",
"93.92893",
"94.40997",
],
],
"roughness": 1,
@ -232,8 +232,8 @@ exports[`move element > rectangles with binding arrow 7`] = `
"updated": 1,
"version": 11,
"versionNonce": 1051383431,
"width": "87.46447",
"x": 110,
"y": 50,
"width": "93.92893",
"x": "103.53553",
"y": "43.53553",
}
`;

View file

@ -128,8 +128,10 @@ describe("move element", () => {
expect(h.state.selectedElementIds[rectB.id]).toBeTruthy();
expect([rectA.x, rectA.y]).toEqual([0, 0]);
expect([rectB.x, rectB.y]).toEqual([201, 2]);
expect([[arrow.x, arrow.y]]).toCloselyEqualPoints([[107.07, 47.07]]);
expect([[arrow.width, arrow.height]]).toCloselyEqualPoints([[86.86, 87.3]]);
expect([[arrow.x, arrow.y]]).toCloselyEqualPoints([[103.54, 43.53]]);
expect([[arrow.width, arrow.height]]).toCloselyEqualPoints([
[93.93, 94.41],
]);
h.elements.forEach((element) => expect(element).toMatchSnapshot());
});