MobileMenu.test.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { UI } from "@excalidraw/excalidraw/tests/helpers/ui";
  2. import {
  3. mockBoundingClientRect,
  4. render,
  5. restoreOriginalGetBoundingClientRect,
  6. } from "@excalidraw/excalidraw/tests/test-utils";
  7. import ExcalidrawApp from "../App";
  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.refreshViewportBreakpoints();
  18. // @ts-ignore
  19. h.app.refreshEditorBreakpoints();
  20. });
  21. afterAll(() => {
  22. restoreOriginalGetBoundingClientRect();
  23. });
  24. it("should set device correctly", () => {
  25. expect(h.app.device).toMatchInlineSnapshot(`
  26. {
  27. "editor": {
  28. "canFitSidebar": false,
  29. "isMobile": true,
  30. },
  31. "isTouchScreen": false,
  32. "viewport": {
  33. "isLandscape": false,
  34. "isMobile": true,
  35. },
  36. }
  37. `);
  38. });
  39. it("should initialize with welcome screen and hide once user interacts", async () => {
  40. expect(document.querySelector(".welcome-screen-center")).toMatchSnapshot();
  41. UI.clickTool("rectangle");
  42. expect(document.querySelector(".welcome-screen-center")).toBeNull();
  43. });
  44. });