mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-11-15 02:04:21 +01:00
fix: Tests
This commit is contained in:
@@ -95,3 +95,141 @@ exports[`move element > rectangle 5`] = `
|
|||||||
"y": 40,
|
"y": 40,
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`move element > rectangles with binding arrow 5`] = `
|
||||||
|
{
|
||||||
|
"angle": 0,
|
||||||
|
"backgroundColor": "transparent",
|
||||||
|
"boundElements": [
|
||||||
|
{
|
||||||
|
"id": "id6",
|
||||||
|
"type": "arrow",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"customData": undefined,
|
||||||
|
"fillStyle": "solid",
|
||||||
|
"frameId": null,
|
||||||
|
"groupIds": [],
|
||||||
|
"height": 100,
|
||||||
|
"id": "id0",
|
||||||
|
"index": "a0",
|
||||||
|
"isDeleted": false,
|
||||||
|
"link": null,
|
||||||
|
"locked": false,
|
||||||
|
"opacity": 100,
|
||||||
|
"roughness": 1,
|
||||||
|
"roundness": null,
|
||||||
|
"seed": 1278240551,
|
||||||
|
"strokeColor": "#1e1e1e",
|
||||||
|
"strokeStyle": "solid",
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"type": "rectangle",
|
||||||
|
"updated": 1,
|
||||||
|
"version": 4,
|
||||||
|
"versionNonce": 760410951,
|
||||||
|
"width": 100,
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`move element > rectangles with binding arrow 6`] = `
|
||||||
|
{
|
||||||
|
"angle": 0,
|
||||||
|
"backgroundColor": "transparent",
|
||||||
|
"boundElements": [
|
||||||
|
{
|
||||||
|
"id": "id6",
|
||||||
|
"type": "arrow",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"customData": undefined,
|
||||||
|
"fillStyle": "solid",
|
||||||
|
"frameId": null,
|
||||||
|
"groupIds": [],
|
||||||
|
"height": 300,
|
||||||
|
"id": "id3",
|
||||||
|
"index": "a1",
|
||||||
|
"isDeleted": false,
|
||||||
|
"link": null,
|
||||||
|
"locked": false,
|
||||||
|
"opacity": 100,
|
||||||
|
"roughness": 1,
|
||||||
|
"roundness": null,
|
||||||
|
"seed": 1116226695,
|
||||||
|
"strokeColor": "#1e1e1e",
|
||||||
|
"strokeStyle": "solid",
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"type": "rectangle",
|
||||||
|
"updated": 1,
|
||||||
|
"version": 7,
|
||||||
|
"versionNonce": 651223591,
|
||||||
|
"width": 300,
|
||||||
|
"x": 201,
|
||||||
|
"y": 2,
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`move element > rectangles with binding arrow 7`] = `
|
||||||
|
{
|
||||||
|
"angle": 0,
|
||||||
|
"backgroundColor": "transparent",
|
||||||
|
"boundElements": null,
|
||||||
|
"customData": undefined,
|
||||||
|
"elbowed": false,
|
||||||
|
"endArrowhead": "arrow",
|
||||||
|
"endBinding": {
|
||||||
|
"elementId": "id3",
|
||||||
|
"fixedPoint": [
|
||||||
|
"-0.02000",
|
||||||
|
"0.44666",
|
||||||
|
],
|
||||||
|
"mode": "orbit",
|
||||||
|
},
|
||||||
|
"fillStyle": "solid",
|
||||||
|
"frameId": null,
|
||||||
|
"groupIds": [],
|
||||||
|
"height": "89.98900",
|
||||||
|
"id": "id6",
|
||||||
|
"index": "a2",
|
||||||
|
"isDeleted": false,
|
||||||
|
"link": null,
|
||||||
|
"locked": false,
|
||||||
|
"moveMidPointsWithElement": false,
|
||||||
|
"opacity": 100,
|
||||||
|
"points": [
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"89.00000",
|
||||||
|
"89.98900",
|
||||||
|
],
|
||||||
|
],
|
||||||
|
"roughness": 1,
|
||||||
|
"roundness": {
|
||||||
|
"type": 2,
|
||||||
|
},
|
||||||
|
"seed": 23633383,
|
||||||
|
"startArrowhead": null,
|
||||||
|
"startBinding": {
|
||||||
|
"elementId": "id0",
|
||||||
|
"fixedPoint": [
|
||||||
|
"1.06000",
|
||||||
|
"0.46011",
|
||||||
|
],
|
||||||
|
"mode": "orbit",
|
||||||
|
},
|
||||||
|
"strokeColor": "#1e1e1e",
|
||||||
|
"strokeStyle": "solid",
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"type": "arrow",
|
||||||
|
"updated": 1,
|
||||||
|
"version": 14,
|
||||||
|
"versionNonce": 348321737,
|
||||||
|
"width": "89.00000",
|
||||||
|
"x": 106,
|
||||||
|
"y": "46.01050",
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|||||||
@@ -1588,7 +1588,7 @@ describe("history", () => {
|
|||||||
expect(API.getUndoStack().length).toBe(5);
|
expect(API.getUndoStack().length).toBe(5);
|
||||||
expect(arrow.startBinding).toEqual({
|
expect(arrow.startBinding).toEqual({
|
||||||
elementId: rect1.id,
|
elementId: rect1.id,
|
||||||
fixedPoint: expect.arrayContaining([1, 0.5001]),
|
fixedPoint: expect.arrayContaining([0.5001, 0.5001]),
|
||||||
mode: "orbit",
|
mode: "orbit",
|
||||||
});
|
});
|
||||||
expect(arrow.endBinding).toEqual({
|
expect(arrow.endBinding).toEqual({
|
||||||
@@ -4621,12 +4621,12 @@ describe("history", () => {
|
|||||||
id: arrowId,
|
id: arrowId,
|
||||||
startBinding: expect.objectContaining({
|
startBinding: expect.objectContaining({
|
||||||
elementId: rect1.id,
|
elementId: rect1.id,
|
||||||
fixedPoint: [1, 0.6],
|
fixedPoint: [0.6363636363636364, 0.6363636363636364],
|
||||||
mode: "orbit",
|
mode: "orbit",
|
||||||
}),
|
}),
|
||||||
endBinding: expect.objectContaining({
|
endBinding: expect.objectContaining({
|
||||||
elementId: rect2.id,
|
elementId: rect2.id,
|
||||||
fixedPoint: [0, 0.6],
|
fixedPoint: [0.4109529004289598, 0.5890470995710405],
|
||||||
mode: "orbit",
|
mode: "orbit",
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -102,16 +102,16 @@ describe("move element", () => {
|
|||||||
new Pointer("mouse").clickOn(rectB);
|
new Pointer("mouse").clickOn(rectB);
|
||||||
|
|
||||||
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
|
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
|
||||||
`15`,
|
`16`,
|
||||||
);
|
);
|
||||||
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`14`);
|
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`15`);
|
||||||
expect(h.state.selectionElement).toBeNull();
|
expect(h.state.selectionElement).toBeNull();
|
||||||
expect(h.elements.length).toEqual(3);
|
expect(h.elements.length).toEqual(3);
|
||||||
expect(h.state.selectedElementIds[rectB.id]).toBeTruthy();
|
expect(h.state.selectedElementIds[rectB.id]).toBeTruthy();
|
||||||
expect([rectA.x, rectA.y]).toEqual([0, 0]);
|
expect([rectA.x, rectA.y]).toEqual([0, 0]);
|
||||||
expect([rectB.x, rectB.y]).toEqual([200, 0]);
|
expect([rectB.x, rectB.y]).toEqual([200, 0]);
|
||||||
expect([[arrow.x, arrow.y]]).toCloselyEqualPoints([[110, 50]], 0);
|
expect([[arrow.x, arrow.y]]).toCloselyEqualPoints([[106, 46.011]], 0);
|
||||||
expect([[arrow.width, arrow.height]]).toCloselyEqualPoints([[80, 80]], 0);
|
expect([[arrow.width, arrow.height]]).toCloselyEqualPoints([[88, 88]], 0);
|
||||||
|
|
||||||
renderInteractiveScene.mockClear();
|
renderInteractiveScene.mockClear();
|
||||||
renderStaticScene.mockClear();
|
renderStaticScene.mockClear();
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ test("unselected bound arrow updates when rotating its target element", async ()
|
|||||||
expect(arrow.endBinding?.elementId).toEqual(rectangle.id);
|
expect(arrow.endBinding?.elementId).toEqual(rectangle.id);
|
||||||
expect(arrow.x).toBeCloseTo(-80);
|
expect(arrow.x).toBeCloseTo(-80);
|
||||||
expect(arrow.y).toBeCloseTo(50);
|
expect(arrow.y).toBeCloseTo(50);
|
||||||
expect(arrow.width).toBeCloseTo(84.9, 1);
|
expect(arrow.width).toBeCloseTo(132.491, 1);
|
||||||
expect(arrow.height).toBeCloseTo(52.717, 1);
|
expect(arrow.height).toBeCloseTo(82.267, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("unselected bound arrows update when rotating their target elements", async () => {
|
test("unselected bound arrows update when rotating their target elements", async () => {
|
||||||
@@ -73,8 +73,8 @@ test("unselected bound arrows update when rotating their target elements", async
|
|||||||
expect(ellipseArrow.x).toEqual(-10);
|
expect(ellipseArrow.x).toEqual(-10);
|
||||||
expect(ellipseArrow.y).toEqual(80);
|
expect(ellipseArrow.y).toEqual(80);
|
||||||
expect(ellipseArrow.points[0]).toEqual([0, 0]);
|
expect(ellipseArrow.points[0]).toEqual([0, 0]);
|
||||||
expect(ellipseArrow.points[1][0]).toBeCloseTo(42.318, 1);
|
expect(ellipseArrow.points[1][0]).toBeCloseTo(66.317, 1);
|
||||||
expect(ellipseArrow.points[1][1]).toBeCloseTo(92.133, 1);
|
expect(ellipseArrow.points[1][1]).toBeCloseTo(144.38, 1);
|
||||||
|
|
||||||
expect(textArrow.endBinding?.elementId).toEqual(text.id);
|
expect(textArrow.endBinding?.elementId).toEqual(text.id);
|
||||||
expect(textArrow.x).toEqual(360);
|
expect(textArrow.x).toEqual(360);
|
||||||
|
|||||||
Reference in New Issue
Block a user