Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b92f585ce7 |
@@ -1,8 +1,7 @@
|
|||||||
import { arrayToMap } from "@excalidraw/common";
|
import { arrayToMap, ROUNDNESS } from "@excalidraw/common";
|
||||||
import { type GlobalPoint, type LocalPoint, pointFrom } from "@excalidraw/math";
|
import { type GlobalPoint, type LocalPoint, pointFrom } from "@excalidraw/math";
|
||||||
import { Excalidraw } from "@excalidraw/excalidraw";
|
import { Excalidraw } from "@excalidraw/excalidraw";
|
||||||
import { API } from "@excalidraw/excalidraw/tests/helpers/api";
|
import { API } from "@excalidraw/excalidraw/tests/helpers/api";
|
||||||
import { UI } from "@excalidraw/excalidraw/tests/helpers/ui";
|
|
||||||
import "@excalidraw/utils/test-utils";
|
import "@excalidraw/utils/test-utils";
|
||||||
import { render } from "@excalidraw/excalidraw/tests/test-utils";
|
import { render } from "@excalidraw/excalidraw/tests/test-utils";
|
||||||
|
|
||||||
@@ -10,29 +9,29 @@ import * as distance from "../src/distance";
|
|||||||
import { hitElementItself } from "../src/collision";
|
import { hitElementItself } from "../src/collision";
|
||||||
|
|
||||||
describe("check rotated elements can be hit:", () => {
|
describe("check rotated elements can be hit:", () => {
|
||||||
beforeEach(async () => {
|
|
||||||
localStorage.clear();
|
|
||||||
await render(<Excalidraw handleKeyboardGlobally={true} />);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("arrow", () => {
|
it("arrow", () => {
|
||||||
UI.createElement("arrow", {
|
const element = API.createElement({
|
||||||
|
type: "arrow",
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
width: 124,
|
width: 124,
|
||||||
height: 302,
|
height: 302,
|
||||||
angle: 1.8700426423973724,
|
angle: 1.8700426423973724,
|
||||||
|
roundness: { type: ROUNDNESS.PROPORTIONAL_RADIUS },
|
||||||
|
endArrowhead: "arrow",
|
||||||
points: [
|
points: [
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[120, -198],
|
[120, -198],
|
||||||
[-4, -302],
|
[-4, -302],
|
||||||
] as LocalPoint[],
|
] as LocalPoint[],
|
||||||
});
|
});
|
||||||
|
const elementsMap = arrayToMap([element]);
|
||||||
|
|
||||||
const hit = hitElementItself({
|
const hit = hitElementItself({
|
||||||
point: pointFrom<GlobalPoint>(88, -68),
|
point: pointFrom<GlobalPoint>(88, -68),
|
||||||
element: window.h.elements[0],
|
element,
|
||||||
threshold: 10,
|
threshold: 10,
|
||||||
elementsMap: window.h.scene.getNonDeletedElementsMap(),
|
elementsMap,
|
||||||
});
|
});
|
||||||
expect(hit).toBe(true);
|
expect(hit).toBe(true);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user