mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
parent
d63b6a3469
commit
60cea7a0c2
8 changed files with 478 additions and 113 deletions
|
@ -13,6 +13,8 @@ import { ImportedDataState } from "../data/types";
|
|||
import { STORAGE_KEYS } from "../excalidraw-app/data/localStorage";
|
||||
|
||||
import { SceneData } from "../types";
|
||||
import { getSelectedElements } from "../scene/selection";
|
||||
import { ExcalidrawElement } from "../element/types";
|
||||
|
||||
const customQueries = {
|
||||
...queries,
|
||||
|
@ -124,3 +126,22 @@ export const mockBoundingClientRect = () => {
|
|||
export const restoreOriginalGetBoundingClientRect = () => {
|
||||
global.window.HTMLDivElement.prototype.getBoundingClientRect = originalGetBoundingClientRect;
|
||||
};
|
||||
|
||||
export const assertSelectedElements = (
|
||||
...elements: (
|
||||
| (ExcalidrawElement["id"] | ExcalidrawElement)[]
|
||||
| ExcalidrawElement["id"]
|
||||
| ExcalidrawElement
|
||||
)[]
|
||||
) => {
|
||||
const { h } = window;
|
||||
const selectedElementIds = getSelectedElements(
|
||||
h.app.getSceneElements(),
|
||||
h.state,
|
||||
).map((el) => el.id);
|
||||
const ids = elements
|
||||
.flat()
|
||||
.map((item) => (typeof item === "string" ? item : item.id));
|
||||
expect(selectedElementIds.length).toBe(ids.length);
|
||||
expect(selectedElementIds).toEqual(expect.arrayContaining(ids));
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue