mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
improve & granularize ExcalidrawElement types (#991)
* improve & granularize ExcalidrawElement types * fix incorrectly passing type * fix tests * fix more tests * fix unnecessary spreads & refactor * add comments
This commit is contained in:
parent
1c545c1d47
commit
373d16abe6
22 changed files with 430 additions and 272 deletions
|
@ -4,6 +4,7 @@ import { App } from "../components/App";
|
|||
import * as Renderer from "../renderer/renderScene";
|
||||
import { KEYS } from "../keys";
|
||||
import { render, fireEvent } from "./test-utils";
|
||||
import { ExcalidrawLinearElement } from "../element/types";
|
||||
|
||||
// Unmount ReactDOM from root
|
||||
ReactDOM.unmountComponentAtNode(document.getElementById("root")!);
|
||||
|
@ -122,12 +123,15 @@ describe("add element to the scene when pointer dragging long enough", () => {
|
|||
expect(h.appState.selectionElement).toBeNull();
|
||||
|
||||
expect(h.elements.length).toEqual(1);
|
||||
expect(h.elements[0].type).toEqual("arrow");
|
||||
expect(h.elements[0].x).toEqual(30);
|
||||
expect(h.elements[0].y).toEqual(20);
|
||||
expect(h.elements[0].points.length).toEqual(2);
|
||||
expect(h.elements[0].points[0]).toEqual([0, 0]);
|
||||
expect(h.elements[0].points[1]).toEqual([30, 50]); // (60 - 30, 70 - 20)
|
||||
|
||||
const element = h.elements[0] as ExcalidrawLinearElement;
|
||||
|
||||
expect(element.type).toEqual("arrow");
|
||||
expect(element.x).toEqual(30);
|
||||
expect(element.y).toEqual(20);
|
||||
expect(element.points.length).toEqual(2);
|
||||
expect(element.points[0]).toEqual([0, 0]);
|
||||
expect(element.points[1]).toEqual([30, 50]); // (60 - 30, 70 - 20)
|
||||
});
|
||||
|
||||
it("line", () => {
|
||||
|
@ -151,12 +155,15 @@ describe("add element to the scene when pointer dragging long enough", () => {
|
|||
expect(h.appState.selectionElement).toBeNull();
|
||||
|
||||
expect(h.elements.length).toEqual(1);
|
||||
expect(h.elements[0].type).toEqual("line");
|
||||
expect(h.elements[0].x).toEqual(30);
|
||||
expect(h.elements[0].y).toEqual(20);
|
||||
expect(h.elements[0].points.length).toEqual(2);
|
||||
expect(h.elements[0].points[0]).toEqual([0, 0]);
|
||||
expect(h.elements[0].points[1]).toEqual([30, 50]); // (60 - 30, 70 - 20)
|
||||
|
||||
const element = h.elements[0] as ExcalidrawLinearElement;
|
||||
|
||||
expect(element.type).toEqual("line");
|
||||
expect(element.x).toEqual(30);
|
||||
expect(element.y).toEqual(20);
|
||||
expect(element.points.length).toEqual(2);
|
||||
expect(element.points[0]).toEqual([0, 0]);
|
||||
expect(element.points[1]).toEqual([30, 50]); // (60 - 30, 70 - 20)
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue