diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /browser/components/asrouter/tests/unit/ModalOverlay.test.jsx | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-upstream/125.0.1.tar.xz firefox-upstream/125.0.1.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/asrouter/tests/unit/ModalOverlay.test.jsx')
-rw-r--r-- | browser/components/asrouter/tests/unit/ModalOverlay.test.jsx | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/browser/components/asrouter/tests/unit/ModalOverlay.test.jsx b/browser/components/asrouter/tests/unit/ModalOverlay.test.jsx deleted file mode 100644 index 2320e16fc3..0000000000 --- a/browser/components/asrouter/tests/unit/ModalOverlay.test.jsx +++ /dev/null @@ -1,69 +0,0 @@ -import { ModalOverlayWrapper } from "content-src/components/ModalOverlay/ModalOverlay"; -import { mount } from "enzyme"; -import React from "react"; - -describe("ModalOverlayWrapper", () => { - let fakeDoc; - let sandbox; - let header; - beforeEach(() => { - sandbox = sinon.createSandbox(); - header = document.createElement("div"); - - fakeDoc = { - addEventListener: sandbox.stub(), - removeEventListener: sandbox.stub(), - body: { classList: { add: sandbox.stub(), remove: sandbox.stub() } }, - getElementById() { - return header; - }, - }; - }); - afterEach(() => { - sandbox.restore(); - }); - it("should add eventListener and a class on mount", async () => { - mount(<ModalOverlayWrapper document={fakeDoc} />); - assert.calledOnce(fakeDoc.addEventListener); - assert.calledWith(fakeDoc.body.classList.add, "modal-open"); - }); - - it("should remove eventListener on unmount", async () => { - const wrapper = mount(<ModalOverlayWrapper document={fakeDoc} />); - wrapper.unmount(); - assert.calledOnce(fakeDoc.addEventListener); - assert.calledOnce(fakeDoc.removeEventListener); - assert.calledWith(fakeDoc.body.classList.remove, "modal-open"); - }); - - it("should call props.onClose on an Escape key", async () => { - const onClose = sandbox.stub(); - mount(<ModalOverlayWrapper document={fakeDoc} onClose={onClose} />); - - // Simulate onkeydown being called - const [, callback] = fakeDoc.addEventListener.firstCall.args; - callback({ key: "Escape" }); - - assert.calledOnce(onClose); - }); - - it("should not call props.onClose on other keys than Escape", async () => { - const onClose = sandbox.stub(); - mount(<ModalOverlayWrapper document={fakeDoc} onClose={onClose} />); - - // Simulate onkeydown being called - const [, callback] = fakeDoc.addEventListener.firstCall.args; - callback({ key: "Ctrl" }); - - assert.notCalled(onClose); - }); - - it("should not call props.onClose when clicked outside dialog", async () => { - const onClose = sandbox.stub(); - const wrapper = mount( - <ModalOverlayWrapper document={fakeDoc} onClose={onClose} /> - ); - wrapper.find("div.modalOverlayOuter.active").simulate("click"); - assert.notCalled(onClose); - }); -}); |