@@ -65,7 +74,7 @@ const Modal = observer(
- ,
+ ,
document.body
);
}
diff --git a/ui/src/Components/Modal/index.test.js b/ui/src/Components/Modal/index.test.js
index bcd9200a3..35e65fcd7 100644
--- a/ui/src/Components/Modal/index.test.js
+++ b/ui/src/Components/Modal/index.test.js
@@ -4,14 +4,20 @@ import { mount } from "enzyme";
import { Modal } from ".";
+const fakeToggle = jest.fn();
+
const MountedModal = isOpen => {
return mount(
-
+
);
};
+afterEach(() => {
+ jest.resetAllMocks();
+});
+
describe("", () => {
it("'modal-open' class is appended to body node when modal is visible", () => {
MountedModal(true);
@@ -32,11 +38,17 @@ describe("", () => {
it("passes extra props down to the MountModal animation component", () => {
const onExited = jest.fn();
const tree = mount(
-
+
);
const mountModal = tree.find("MountModal");
expect(mountModal.props().onExited).toBe(onExited);
});
+
+ it("toggleOpen is called after pressing 'esc'", () => {
+ const tree = MountedModal(true);
+ tree.simulate("keyDown", { key: "Escape", keyCode: 27, which: 27 });
+ expect(fakeToggle).toHaveBeenCalled();
+ });
});
diff --git a/ui/src/Components/OverviewModal/index.js b/ui/src/Components/OverviewModal/index.js
index 468dc4bff..2263870e2 100644
--- a/ui/src/Components/OverviewModal/index.js
+++ b/ui/src/Components/OverviewModal/index.js
@@ -58,7 +58,11 @@ const OverviewModal = observer(