Refactor (#862)
* Initial factoring out of parts of the LayerUI component 2360 → 2224 LOC * Create a Section component * Break up src/index.tsx * Refactor actions to reduce duplication, fix CSS Also consolidate icons * Move scene/data.ts to its own directory * Fix accidental reverts, banish further single-character variables * ACTIVE_ELEM_COLOR → ACTIVE_ELEMENT_COLOR * Further refactoring the icons file * Log all errors * Pointer Event polyfill to make the tests work * add test hooks & fix tests Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { render, fireEvent } from "./test-utils";
|
||||
import { App } from "../index";
|
||||
import { App } from "../components/App";
|
||||
import * as Renderer from "../renderer/renderScene";
|
||||
import { KEYS } from "../keys";
|
||||
|
||||
@ -14,7 +14,9 @@ beforeEach(() => {
|
||||
renderScene.mockClear();
|
||||
});
|
||||
|
||||
describe.skip("remove shape in non linear elements", () => {
|
||||
const { __TEST__: h } = window;
|
||||
|
||||
describe("remove shape in non linear elements", () => {
|
||||
it("rectangle", () => {
|
||||
const { getByToolName, container } = render(<App />);
|
||||
// select tool
|
||||
@ -26,8 +28,7 @@ describe.skip("remove shape in non linear elements", () => {
|
||||
fireEvent.pointerUp(canvas, { clientX: 30, clientY: 30 });
|
||||
|
||||
expect(renderScene).toHaveBeenCalledTimes(3);
|
||||
const elements = renderScene.mock.calls[2][0];
|
||||
expect(elements.length).toEqual(0);
|
||||
expect(h.elements.length).toEqual(0);
|
||||
});
|
||||
|
||||
it("ellipse", () => {
|
||||
@ -41,8 +42,7 @@ describe.skip("remove shape in non linear elements", () => {
|
||||
fireEvent.pointerUp(canvas, { clientX: 30, clientY: 30 });
|
||||
|
||||
expect(renderScene).toHaveBeenCalledTimes(3);
|
||||
const elements = renderScene.mock.calls[2][0];
|
||||
expect(elements.length).toEqual(0);
|
||||
expect(h.elements.length).toEqual(0);
|
||||
});
|
||||
|
||||
it("diamond", () => {
|
||||
@ -56,12 +56,11 @@ describe.skip("remove shape in non linear elements", () => {
|
||||
fireEvent.pointerUp(canvas, { clientX: 30, clientY: 30 });
|
||||
|
||||
expect(renderScene).toHaveBeenCalledTimes(3);
|
||||
const elements = renderScene.mock.calls[2][0];
|
||||
expect(elements.length).toEqual(0);
|
||||
expect(h.elements.length).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe.skip("multi point mode in linear elements", () => {
|
||||
describe("multi point mode in linear elements", () => {
|
||||
it("arrow", () => {
|
||||
const { getByToolName, container } = render(<App />);
|
||||
// select tool
|
||||
@ -86,14 +85,13 @@ describe.skip("multi point mode in linear elements", () => {
|
||||
fireEvent.pointerUp(canvas);
|
||||
fireEvent.keyDown(document, { key: KEYS.ENTER });
|
||||
|
||||
expect(renderScene).toHaveBeenCalledTimes(8);
|
||||
const elements = renderScene.mock.calls[7][0];
|
||||
expect(elements.length).toEqual(1);
|
||||
expect(renderScene).toHaveBeenCalledTimes(10);
|
||||
expect(h.elements.length).toEqual(1);
|
||||
|
||||
expect(elements[0].type).toEqual("arrow");
|
||||
expect(elements[0].x).toEqual(30);
|
||||
expect(elements[0].y).toEqual(30);
|
||||
expect(elements[0].points).toEqual([
|
||||
expect(h.elements[0].type).toEqual("arrow");
|
||||
expect(h.elements[0].x).toEqual(30);
|
||||
expect(h.elements[0].y).toEqual(30);
|
||||
expect(h.elements[0].points).toEqual([
|
||||
[0, 0],
|
||||
[20, 30],
|
||||
[70, 110],
|
||||
@ -124,14 +122,13 @@ describe.skip("multi point mode in linear elements", () => {
|
||||
fireEvent.pointerUp(canvas);
|
||||
fireEvent.keyDown(document, { key: KEYS.ENTER });
|
||||
|
||||
expect(renderScene).toHaveBeenCalledTimes(8);
|
||||
const elements = renderScene.mock.calls[7][0];
|
||||
expect(elements.length).toEqual(1);
|
||||
expect(renderScene).toHaveBeenCalledTimes(10);
|
||||
expect(h.elements.length).toEqual(1);
|
||||
|
||||
expect(elements[0].type).toEqual("line");
|
||||
expect(elements[0].x).toEqual(30);
|
||||
expect(elements[0].y).toEqual(30);
|
||||
expect(elements[0].points).toEqual([
|
||||
expect(h.elements[0].type).toEqual("line");
|
||||
expect(h.elements[0].x).toEqual(30);
|
||||
expect(h.elements[0].y).toEqual(30);
|
||||
expect(h.elements[0].points).toEqual([
|
||||
[0, 0],
|
||||
[20, 30],
|
||||
[70, 110],
|
||||
|
Reference in New Issue
Block a user