Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 1103d87

Browse files
committed
fix: valid dialog test
1 parent 8bef163 commit 1103d87

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/features/Apiexplorer/ValidDialog/__tests__/ValidDialog.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import ValidDialog from '..';
33
import { screen, render } from '@testing-library/react';
4+
import userEvent from '@testing-library/user-event';
45

56
describe('ValidDialog', () => {
67
test('if correct test is rendered', () => {
@@ -13,4 +14,19 @@ describe('ValidDialog', () => {
1314

1415
expect(text).toBeVisible();
1516
});
17+
it('should close popup when clicking on close button', async () => {
18+
const setIsNotValid = jest.fn();
19+
const setToggleModal = jest.fn();
20+
21+
render(<ValidDialog setIsNotValid={setIsNotValid} setToggleModal={setToggleModal} />);
22+
const modal = screen.getByText(
23+
'Your JSON object is invalid. Please make sure you provide the correct syntax for your JSON object.',
24+
);
25+
const close_button = screen.getByTestId('close-button');
26+
await userEvent.click(close_button);
27+
28+
expect(modal).not.toBeInTheDocument();
29+
expect(setIsNotValid).toHaveBeenCalled();
30+
expect(setToggleModal).toHaveBeenCalled();
31+
});
1632
});

0 commit comments

Comments
 (0)