aboutsummaryrefslogtreecommitdiffstats
path: root/packages/excalidraw/element/typeChecks.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/excalidraw/element/typeChecks.test.ts')
-rw-r--r--packages/excalidraw/element/typeChecks.test.ts66
1 files changed, 66 insertions, 0 deletions
diff --git a/packages/excalidraw/element/typeChecks.test.ts b/packages/excalidraw/element/typeChecks.test.ts
new file mode 100644
index 0000000..60eb9e2
--- /dev/null
+++ b/packages/excalidraw/element/typeChecks.test.ts
@@ -0,0 +1,66 @@
+import { API } from "../tests/helpers/api";
+import { hasBoundTextElement } from "./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();
+ });
+});