-
Outside content
+ closeButton.click();
+
+ expect(onClose).toHaveBeenCalledTimes(1);
+ });
+
+ it('should close when Escape is pressed', async () => {
+ const onClose = jest.fn();
+ render(
+
+ This is the modal body content
+ ,
+ );
+
+ await user.keyboard('{Escape}');
+ expect(onClose).toHaveBeenCalledTimes(1);
+ });
+
+ it("shouldn't close on outside click by default", async () => {
+ const onClose = jest.fn();
+ const { getByText } = render(
+
+
Outside content
+
+ This is the modal body content
+
+
,
+ );
+
+ await user.click(getByText('Outside content'));
+ expect(onClose).not.toHaveBeenCalled();
+ });
+
+ it('should close on click outside, if enabled', async () => {
+ const onClose = jest.fn();
+ const { getByText } = render(
+
+
Outside content
+
+ This is the modal body content
+
+
,
+ );
+
+ await user.click(getByText('Outside content'));
+ expect(onClose).toHaveBeenCalledTimes(1);
+ });
+
+ it('should render with additional class names', async () => {
+ const { getByTestId } = render(
This is the modal body content
-
-
,
- );
+ ,
+ );
- await userEvent.click(getByText('Outside content'));
- expect(onClose).toHaveBeenCalledTimes(1);
-});
-
-it('should render with additional class names', async () => {
- const { getByTestId } = render(
-