snapshot of https://github.com/excalidraw/excalidraw.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Tests / test (push) Failing after 15s
Some checks failed
Tests / test (push) Failing after 15s
This commit is contained in:
60
packages/excalidraw/tests/freedrawMode.test.tsx
Normal file
60
packages/excalidraw/tests/freedrawMode.test.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
import type {
|
||||
ExcalidrawFreeDrawElement,
|
||||
NonDeletedExcalidrawElement,
|
||||
} from "@excalidraw/element/types";
|
||||
|
||||
import { Excalidraw } from "../index";
|
||||
|
||||
import { API } from "./helpers/api";
|
||||
import { UI } from "./helpers/ui";
|
||||
import { act, fireEvent, render, screen } from "./test-utils";
|
||||
|
||||
const { h } = window;
|
||||
|
||||
describe("freedraw mode action", () => {
|
||||
beforeEach(async () => {
|
||||
await render(<Excalidraw handleKeyboardGlobally={true} />);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
// https://github.com/floating-ui/floating-ui/issues/1908#issuecomment-1301553793
|
||||
await act(async () => {});
|
||||
});
|
||||
|
||||
it("applies currentItemStrokeVariability to newly drawn freedraw elements", () => {
|
||||
// default app state draws constant-width strokes
|
||||
expect(h.state.currentItemStrokeVariability).toBe("constant");
|
||||
|
||||
UI.createElement("freedraw", { x: 0, y: 0 });
|
||||
|
||||
expect(
|
||||
(h.elements[0] as ExcalidrawFreeDrawElement).strokeOptions?.variability,
|
||||
).toBe("constant");
|
||||
expect(
|
||||
(h.elements[0] as ExcalidrawFreeDrawElement).strokeOptions?.streamline,
|
||||
).toBe(0.5);
|
||||
});
|
||||
|
||||
it("toggling the radio updates both the selected element and the default", () => {
|
||||
const element = UI.createElement("freedraw", { x: 0, y: 0 });
|
||||
API.setSelectedElements([element.get()] as NonDeletedExcalidrawElement[]);
|
||||
|
||||
fireEvent.click(screen.getByTitle("Variable"));
|
||||
expect(
|
||||
(h.elements[0] as ExcalidrawFreeDrawElement).strokeOptions?.variability,
|
||||
).toBe("variable");
|
||||
expect(
|
||||
(h.elements[0] as ExcalidrawFreeDrawElement).strokeOptions?.streamline,
|
||||
).toBe(0.5);
|
||||
expect(h.state.currentItemStrokeVariability).toBe("variable");
|
||||
|
||||
fireEvent.click(screen.getByTitle("Constant"));
|
||||
expect(
|
||||
(h.elements[0] as ExcalidrawFreeDrawElement).strokeOptions?.variability,
|
||||
).toBe("constant");
|
||||
expect(
|
||||
(h.elements[0] as ExcalidrawFreeDrawElement).strokeOptions?.streamline,
|
||||
).toBe(0.5);
|
||||
expect(h.state.currentItemStrokeVariability).toBe("constant");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user