|
|
|
@ -173,14 +173,14 @@ describe("Test Linear Elements", () => {
|
|
|
|
|
createTwoPointerLinearElement("line");
|
|
|
|
|
const line = h.elements[0] as ExcalidrawLinearElement;
|
|
|
|
|
|
|
|
|
|
expect(renderInteractiveScene).toHaveBeenCalledTimes(5);
|
|
|
|
|
expect(renderStaticScene).toHaveBeenCalledTimes(5);
|
|
|
|
|
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(`5`);
|
|
|
|
|
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`5`);
|
|
|
|
|
expect((h.elements[0] as ExcalidrawLinearElement).points.length).toEqual(2);
|
|
|
|
|
|
|
|
|
|
// drag line from midpoint
|
|
|
|
|
drag(midpoint, [midpoint[0] + delta, midpoint[1] + delta]);
|
|
|
|
|
expect(renderInteractiveScene).toHaveBeenCalledTimes(9);
|
|
|
|
|
expect(renderStaticScene).toHaveBeenCalledTimes(7);
|
|
|
|
|
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(`9`);
|
|
|
|
|
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`7`);
|
|
|
|
|
expect(line.points.length).toEqual(3);
|
|
|
|
|
expect(line.points).toMatchInlineSnapshot(`
|
|
|
|
|
[
|
|
|
|
@ -273,8 +273,10 @@ describe("Test Linear Elements", () => {
|
|
|
|
|
|
|
|
|
|
// drag line from midpoint
|
|
|
|
|
drag(midpoint, [midpoint[0] + delta, midpoint[1] + delta]);
|
|
|
|
|
expect(renderInteractiveScene).toHaveBeenCalledTimes(14);
|
|
|
|
|
expect(renderStaticScene).toHaveBeenCalledTimes(6);
|
|
|
|
|
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
|
|
|
|
|
`12`,
|
|
|
|
|
);
|
|
|
|
|
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`6`);
|
|
|
|
|
|
|
|
|
|
expect(line.points.length).toEqual(3);
|
|
|
|
|
expect(line.points).toMatchInlineSnapshot(`
|
|
|
|
@ -311,8 +313,10 @@ describe("Test Linear Elements", () => {
|
|
|
|
|
// update roundness
|
|
|
|
|
fireEvent.click(screen.getByTitle("Round"));
|
|
|
|
|
|
|
|
|
|
expect(renderInteractiveScene).toHaveBeenCalledTimes(10);
|
|
|
|
|
expect(renderStaticScene).toHaveBeenCalledTimes(8);
|
|
|
|
|
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
|
|
|
|
|
`10`,
|
|
|
|
|
);
|
|
|
|
|
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`8`);
|
|
|
|
|
|
|
|
|
|
const midPointsWithRoundEdge = LinearElementEditor.getEditorMidPoints(
|
|
|
|
|
h.elements[0] as ExcalidrawLinearElement,
|
|
|
|
@ -357,8 +361,10 @@ describe("Test Linear Elements", () => {
|
|
|
|
|
// Move the element
|
|
|
|
|
drag(startPoint, endPoint);
|
|
|
|
|
|
|
|
|
|
expect(renderInteractiveScene).toHaveBeenCalledTimes(14);
|
|
|
|
|
expect(renderStaticScene).toHaveBeenCalledTimes(9);
|
|
|
|
|
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
|
|
|
|
|
`13`,
|
|
|
|
|
);
|
|
|
|
|
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`9`);
|
|
|
|
|
|
|
|
|
|
expect([line.x, line.y]).toEqual([
|
|
|
|
|
points[0][0] + deltaX,
|
|
|
|
@ -416,8 +422,10 @@ describe("Test Linear Elements", () => {
|
|
|
|
|
lastSegmentMidpoint[1] + delta,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
expect(renderInteractiveScene).toHaveBeenCalledTimes(21);
|
|
|
|
|
expect(renderStaticScene).toHaveBeenCalledTimes(9);
|
|
|
|
|
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
|
|
|
|
|
`17`,
|
|
|
|
|
);
|
|
|
|
|
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`9`);
|
|
|
|
|
|
|
|
|
|
expect(line.points.length).toEqual(5);
|
|
|
|
|
|
|
|
|
@ -457,8 +465,10 @@ describe("Test Linear Elements", () => {
|
|
|
|
|
// Drag from first point
|
|
|
|
|
drag(hitCoords, [hitCoords[0] - delta, hitCoords[1] - delta]);
|
|
|
|
|
|
|
|
|
|
expect(renderInteractiveScene).toHaveBeenCalledTimes(14);
|
|
|
|
|
expect(renderStaticScene).toHaveBeenCalledTimes(8);
|
|
|
|
|
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
|
|
|
|
|
`13`,
|
|
|
|
|
);
|
|
|
|
|
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`8`);
|
|
|
|
|
|
|
|
|
|
const newPoints = LinearElementEditor.getPointsGlobalCoordinates(line);
|
|
|
|
|
expect([newPoints[0][0], newPoints[0][1]]).toEqual([
|
|
|
|
@ -484,8 +494,10 @@ describe("Test Linear Elements", () => {
|
|
|
|
|
// Drag from first point
|
|
|
|
|
drag(hitCoords, [hitCoords[0] + delta, hitCoords[1] + delta]);
|
|
|
|
|
|
|
|
|
|
expect(renderInteractiveScene).toHaveBeenCalledTimes(14);
|
|
|
|
|
expect(renderStaticScene).toHaveBeenCalledTimes(8);
|
|
|
|
|
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
|
|
|
|
|
`13`,
|
|
|
|
|
);
|
|
|
|
|
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`8`);
|
|
|
|
|
|
|
|
|
|
const newPoints = LinearElementEditor.getPointsGlobalCoordinates(line);
|
|
|
|
|
expect([newPoints[0][0], newPoints[0][1]]).toEqual([
|
|
|
|
@ -519,8 +531,10 @@ describe("Test Linear Elements", () => {
|
|
|
|
|
// delete 3rd point
|
|
|
|
|
deletePoint(points[2]);
|
|
|
|
|
expect(line.points.length).toEqual(3);
|
|
|
|
|
expect(renderInteractiveScene).toHaveBeenCalledTimes(21);
|
|
|
|
|
expect(renderStaticScene).toHaveBeenCalledTimes(9);
|
|
|
|
|
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
|
|
|
|
|
`19`,
|
|
|
|
|
);
|
|
|
|
|
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`9`);
|
|
|
|
|
|
|
|
|
|
const newMidPoints = LinearElementEditor.getEditorMidPoints(
|
|
|
|
|
line,
|
|
|
|
@ -566,8 +580,10 @@ describe("Test Linear Elements", () => {
|
|
|
|
|
lastSegmentMidpoint[0] + delta,
|
|
|
|
|
lastSegmentMidpoint[1] + delta,
|
|
|
|
|
]);
|
|
|
|
|
expect(renderInteractiveScene).toHaveBeenCalledTimes(21);
|
|
|
|
|
expect(renderStaticScene).toHaveBeenCalledTimes(9);
|
|
|
|
|
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
|
|
|
|
|
`17`,
|
|
|
|
|
);
|
|
|
|
|
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`9`);
|
|
|
|
|
expect(line.points.length).toEqual(5);
|
|
|
|
|
|
|
|
|
|
expect((h.elements[0] as ExcalidrawLinearElement).points)
|
|
|
|
@ -642,8 +658,10 @@ describe("Test Linear Elements", () => {
|
|
|
|
|
// Drag from first point
|
|
|
|
|
drag(hitCoords, [hitCoords[0] + delta, hitCoords[1] + delta]);
|
|
|
|
|
|
|
|
|
|
expect(renderInteractiveScene).toHaveBeenCalledTimes(14);
|
|
|
|
|
expect(renderStaticScene).toHaveBeenCalledTimes(8);
|
|
|
|
|
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
|
|
|
|
|
`13`,
|
|
|
|
|
);
|
|
|
|
|
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`8`);
|
|
|
|
|
|
|
|
|
|
const newPoints = LinearElementEditor.getPointsGlobalCoordinates(line);
|
|
|
|
|
expect([newPoints[0][0], newPoints[0][1]]).toEqual([
|
|
|
|
|