From 6ec259a0e71174651bae95d4628138bf6fd68742 Mon Sep 17 00:00:00 2001
From: kj_sh604
Date: Sun, 15 Mar 2026 16:19:35 -0400
Subject: refactor: packages/

---
 .../components/hoc/withInternalFallback.test.tsx   | 101 +++++++++++++++++++++
 1 file changed, 101 insertions(+)
 create mode 100644 packages/excalidraw/components/hoc/withInternalFallback.test.tsx

(limited to 'packages/excalidraw/components/hoc/withInternalFallback.test.tsx')

diff --git a/packages/excalidraw/components/hoc/withInternalFallback.test.tsx b/packages/excalidraw/components/hoc/withInternalFallback.test.tsx
new file mode 100644
index 0000000..5543133
--- /dev/null
+++ b/packages/excalidraw/components/hoc/withInternalFallback.test.tsx
@@ -0,0 +1,101 @@
+import React from "react";
+import { render, queryAllByTestId } from "../../tests/test-utils";
+import { Excalidraw, MainMenu } from "../../index";
+
+describe("Test internal component fallback rendering", () => {
+  it("should render only one menu per excalidraw instance (custom menu first scenario)", async () => {
+    const { container } = await render(
+      <div>
+        <Excalidraw>
+          <MainMenu>test</MainMenu>
+        </Excalidraw>
+        <Excalidraw />
+      </div>,
+    );
+
+    expect(queryAllByTestId(container, "main-menu-trigger")?.length).toBe(2);
+
+    const excalContainers = container.querySelectorAll<HTMLDivElement>(
+      ".excalidraw-container",
+    );
+
+    expect(
+      queryAllByTestId(excalContainers[0], "main-menu-trigger")?.length,
+    ).toBe(1);
+    expect(
+      queryAllByTestId(excalContainers[1], "main-menu-trigger")?.length,
+    ).toBe(1);
+  });
+
+  it("should render only one menu per excalidraw instance (default menu first scenario)", async () => {
+    const { container } = await render(
+      <div>
+        <Excalidraw />
+        <Excalidraw>
+          <MainMenu>test</MainMenu>
+        </Excalidraw>
+      </div>,
+    );
+
+    expect(queryAllByTestId(container, "main-menu-trigger")?.length).toBe(2);
+
+    const excalContainers = container.querySelectorAll<HTMLDivElement>(
+      ".excalidraw-container",
+    );
+
+    expect(
+      queryAllByTestId(excalContainers[0], "main-menu-trigger")?.length,
+    ).toBe(1);
+    expect(
+      queryAllByTestId(excalContainers[1], "main-menu-trigger")?.length,
+    ).toBe(1);
+  });
+
+  it("should render only one menu per excalidraw instance (two custom menus scenario)", async () => {
+    const { container } = await render(
+      <div>
+        <Excalidraw>
+          <MainMenu>test</MainMenu>
+        </Excalidraw>
+        <Excalidraw>
+          <MainMenu>test</MainMenu>
+        </Excalidraw>
+      </div>,
+    );
+
+    expect(queryAllByTestId(container, "main-menu-trigger")?.length).toBe(2);
+
+    const excalContainers = container.querySelectorAll<HTMLDivElement>(
+      ".excalidraw-container",
+    );
+
+    expect(
+      queryAllByTestId(excalContainers[0], "main-menu-trigger")?.length,
+    ).toBe(1);
+    expect(
+      queryAllByTestId(excalContainers[1], "main-menu-trigger")?.length,
+    ).toBe(1);
+  });
+
+  it("should render only one menu per excalidraw instance (two default menus scenario)", async () => {
+    const { container } = await render(
+      <div>
+        <Excalidraw />
+        <Excalidraw />
+      </div>,
+    );
+
+    expect(queryAllByTestId(container, "main-menu-trigger")?.length).toBe(2);
+
+    const excalContainers = container.querySelectorAll<HTMLDivElement>(
+      ".excalidraw-container",
+    );
+
+    expect(
+      queryAllByTestId(excalContainers[0], "main-menu-trigger")?.length,
+    ).toBe(1);
+    expect(
+      queryAllByTestId(excalContainers[1], "main-menu-trigger")?.length,
+    ).toBe(1);
+  });
+});
-- 
cgit v1.2.3

