MobileMenu.test.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import ExcalidrawApp from "../../excalidraw-app";
  2. import {
  3. mockBoundingClientRect,
  4. render,
  5. restoreOriginalGetBoundingClientRect,
  6. } from "../../src/tests/test-utils";
  7. import { UI } from "../../src/tests/helpers/ui";
  8. describe("Test MobileMenu", () => {
  9. const { h } = window;
  10. const dimensions = { height: 400, width: 800 };
  11. beforeAll(() => {
  12. mockBoundingClientRect(dimensions);
  13. });
  14. beforeEach(async () => {
  15. await render(<ExcalidrawApp />);
  16. //@ts-ignore
  17. h.app.refreshDeviceState(h.app.excalidrawContainerRef.current!);
  18. });
  19. afterAll(() => {
  20. restoreOriginalGetBoundingClientRect();
  21. });
  22. it("should set device correctly", () => {
  23. expect(h.app.device).toMatchInlineSnapshot(`
  24. {
  25. "canDeviceFitSidebar": false,
  26. "isLandscape": true,
  27. "isMobile": true,
  28. "isSmScreen": false,
  29. "isTouchScreen": false,
  30. }
  31. `);
  32. });
  33. it("should initialize with welcome screen and hide once user interacts", async () => {
  34. expect(document.querySelector(".welcome-screen-center")).toMatchSnapshot();
  35. UI.clickTool("rectangle");
  36. expect(document.querySelector(".welcome-screen-center")).toBeNull();
  37. });
  38. });