2023-09-21 09:28:48 +05:30
|
|
|
import ExcalidrawApp from "../../excalidraw-app";
|
2023-02-02 12:58:45 +05:30
|
|
|
import {
|
|
|
|
mockBoundingClientRect,
|
|
|
|
render,
|
|
|
|
restoreOriginalGetBoundingClientRect,
|
2023-09-21 09:28:48 +05:30
|
|
|
} from "../../src/tests/test-utils";
|
2023-02-02 12:58:45 +05:30
|
|
|
|
2023-09-21 09:28:48 +05:30
|
|
|
import { UI } from "../../src/tests/helpers/ui";
|
2023-02-02 12:58:45 +05:30
|
|
|
|
|
|
|
describe("Test MobileMenu", () => {
|
|
|
|
const { h } = window;
|
|
|
|
const dimensions = { height: 400, width: 800 };
|
|
|
|
|
2023-07-27 23:50:11 +05:30
|
|
|
beforeAll(() => {
|
|
|
|
mockBoundingClientRect(dimensions);
|
|
|
|
});
|
|
|
|
|
2023-02-02 12:58:45 +05:30
|
|
|
beforeEach(async () => {
|
|
|
|
await render(<ExcalidrawApp />);
|
2023-11-06 16:29:00 +01:00
|
|
|
// @ts-ignore
|
|
|
|
h.app.refreshViewportBreakpoints();
|
|
|
|
// @ts-ignore
|
|
|
|
h.app.refreshEditorBreakpoints();
|
2023-02-02 12:58:45 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(() => {
|
|
|
|
restoreOriginalGetBoundingClientRect();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should set device correctly", () => {
|
|
|
|
expect(h.app.device).toMatchInlineSnapshot(`
|
2023-07-27 23:50:11 +05:30
|
|
|
{
|
2023-11-06 16:29:00 +01:00
|
|
|
"editor": {
|
|
|
|
"canFitSidebar": false,
|
|
|
|
"isMobile": true,
|
|
|
|
},
|
2023-02-02 12:58:45 +05:30
|
|
|
"isTouchScreen": false,
|
2023-11-06 16:29:00 +01:00
|
|
|
"viewport": {
|
|
|
|
"isLandscape": false,
|
|
|
|
"isMobile": true,
|
|
|
|
},
|
2023-02-02 12:58:45 +05:30
|
|
|
}
|
|
|
|
`);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should initialize with welcome screen and hide once user interacts", async () => {
|
|
|
|
expect(document.querySelector(".welcome-screen-center")).toMatchSnapshot();
|
|
|
|
UI.clickTool("rectangle");
|
|
|
|
expect(document.querySelector(".welcome-screen-center")).toBeNull();
|
|
|
|
});
|
|
|
|
});
|