diff --git a/assets/tests/components/modal.test.tsx b/assets/tests/components/modal.test.tsx index 840346faf..4729335c0 100644 --- a/assets/tests/components/modal.test.tsx +++ b/assets/tests/components/modal.test.tsx @@ -1,6 +1,7 @@ import { jest, describe, test, expect } from "@jest/globals" +import "@testing-library/jest-dom/jest-globals" import React from "react" -import { render } from "@testing-library/react" +import { render, screen, waitFor } from "@testing-library/react" import Modal from "../../src/components/modal" import { StateDispatchProvider } from "../../src/contexts/stateDispatchContext" import { useMinischeduleRuns } from "../../src/hooks/useMinischedule" @@ -12,6 +13,8 @@ import { import { initialState, State } from "../../src/state" import stateFactory from "../factories/applicationState" import { viewFactory } from "../factories/pagePanelStateFactory" +import userEvent from "@testing-library/user-event" +import { RealDispatchWrapper } from "../testHelpers/wrappers" jest.mock("../../src/hooks/useMinischedule", () => ({ __esModule: true, @@ -105,6 +108,29 @@ describe("Modal", () => { expect(result.getByText("Save open routes as preset")).not.toBeNull() }) + test("create preset modal closes on escape", async () => { + const createCallback = jest.fn() + const confirmOverwriteCallback = jest.fn() + + render( + + + + ) + const modal = screen.getByText("Save open routes as preset") + expect(modal).toBeVisible() + userEvent.keyboard("{Escape}") + await waitFor(() => expect(modal).not.toBeInTheDocument()) + }) + test("renders save preset modal", () => { const saveCallback = jest.fn()