| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import { API } from "@excalidraw/excalidraw/tests/helpers/api";
- import { hasBoundTextElement } from "../src/typeChecks";
- describe("Test TypeChecks", () => {
- describe("Test hasBoundTextElement", () => {
- it("should return true for text bindable containers with bound text", () => {
- expect(
- hasBoundTextElement(
- API.createElement({
- type: "rectangle",
- boundElements: [{ type: "text", id: "text-id" }],
- }),
- ),
- ).toBeTruthy();
- expect(
- hasBoundTextElement(
- API.createElement({
- type: "ellipse",
- boundElements: [{ type: "text", id: "text-id" }],
- }),
- ),
- ).toBeTruthy();
- expect(
- hasBoundTextElement(
- API.createElement({
- type: "arrow",
- boundElements: [{ type: "text", id: "text-id" }],
- }),
- ),
- ).toBeTruthy();
- });
- it("should return false for text bindable containers without bound text", () => {
- expect(
- hasBoundTextElement(
- API.createElement({
- type: "freedraw",
- boundElements: [{ type: "arrow", id: "arrow-id" }],
- }),
- ),
- ).toBeFalsy();
- });
- it("should return false for non text bindable containers", () => {
- expect(
- hasBoundTextElement(
- API.createElement({
- type: "freedraw",
- boundElements: [{ type: "text", id: "text-id" }],
- }),
- ),
- ).toBeFalsy();
- });
- expect(
- hasBoundTextElement(
- API.createElement({
- type: "image",
- boundElements: [{ type: "text", id: "text-id" }],
- }),
- ),
- ).toBeFalsy();
- });
- });
|