This repository was archived by the owner on May 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
src/features/Apiexplorer/ValidDialog/__tests__ Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 11import React from 'react' ;
22import ValidDialog from '..' ;
33import { screen , render } from '@testing-library/react' ;
4+ import userEvent from '@testing-library/user-event' ;
45
56describe ( '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} ) ;
You can’t perform that action at this time.
0 commit comments