diff --git a/src/features/Apiexplorer/ValidDialog/__tests__/ValidDialog.test.tsx b/src/features/Apiexplorer/ValidDialog/__tests__/ValidDialog.test.tsx index 127b048f..c45309f8 100644 --- a/src/features/Apiexplorer/ValidDialog/__tests__/ValidDialog.test.tsx +++ b/src/features/Apiexplorer/ValidDialog/__tests__/ValidDialog.test.tsx @@ -1,6 +1,7 @@ import React from 'react'; import ValidDialog from '..'; import { screen, render } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; describe('ValidDialog', () => { test('if correct test is rendered', () => { @@ -13,4 +14,19 @@ describe('ValidDialog', () => { expect(text).toBeVisible(); }); + it('should close popup when clicking on close button', async () => { + const setIsNotValid = jest.fn(); + const setToggleModal = jest.fn(); + + render(); + const modal = screen.getByText( + 'Your JSON object is invalid. Please make sure you provide the correct syntax for your JSON object.', + ); + const close_button = screen.getByTestId('close-button'); + await userEvent.click(close_button); + + expect(modal).not.toBeInTheDocument(); + expect(setIsNotValid).toHaveBeenCalled(); + expect(setToggleModal).toHaveBeenCalled(); + }); });