Last active
October 26, 2022 17:48
-
-
Save MrJadaml/ee67849445a26d19a30af8e103963258 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Modal = ({ children, onClose }) => ( | |
<div role="presentation"> | |
<OutsideClickHandler onOutsideClick={onClose}> | |
<div> modal stuff... </div> | |
</OutsideClickHandler> | |
</div> | |
) | |
it('should close modal when clicked outside', () => { | |
const mockHandleClose = jest.fn() | |
render(<Modal {...props} onClose={mockHandleClose} />) | |
fireEvent.click(document) | |
// userEvent.click(document.body) -- Tried this as well with no luck | |
expect(mockHandleClose).toBeCalled() | |
}) | |
// Test output: | |
// expect(jest.fn()).toBeCalled() | |
// Expected number of calls: >= 1 | |
// Received number of calls: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment