@@ -79,35 +79,37 @@ describe("Validation step tests", () => {
7979 } )
8080
8181 test ( "Submit data with a unsuccessful async return" , async ( ) => {
82+ const ERROR_MESSAGE = "ERROR has occurred"
8283 const onReject = jest . fn ( )
8384 const onSubmit = jest . fn ( async ( ) : Promise < void > => {
8485 onReject ( )
85- return Promise . reject ( )
86+ throw new Error ( ERROR_MESSAGE )
8687 } )
8788 const onClose = jest . fn ( )
88- try {
89- render (
90- < Providers theme = { defaultTheme } rsiValues = { { ...mockValues , onSubmit, onClose } } >
91- < ModalWrapper isOpen = { true } onClose = { ( ) => { } } >
92- < ValidationStep initialData = { [ ] } file = { file } />
93- </ ModalWrapper >
94- </ Providers > ,
95- )
9689
97- const finishButton = screen . getByRole ( "button" , {
98- name : "Confirm" ,
99- } )
90+ render (
91+ < Providers theme = { defaultTheme } rsiValues = { { ...mockValues , onSubmit, onClose } } >
92+ < ModalWrapper isOpen = { true } onClose = { ( ) => { } } >
93+ < ValidationStep initialData = { [ ] } file = { file } />
94+ </ ModalWrapper >
95+ </ Providers > ,
96+ )
10097
101- await userEvent . click ( finishButton )
98+ const finishButton = screen . getByRole ( "button" , {
99+ name : "Confirm" ,
100+ } )
101+
102+ await userEvent . click ( finishButton )
102103
103- await waitFor ( ( ) => {
104- expect ( onSubmit ) . toBeCalledWith ( { all : [ ] , invalidData : [ ] , validData : [ ] } , file )
105- } )
106- } catch ( e ) { }
107104 await waitFor ( ( ) => {
108- expect ( onReject ) . toBeCalled ( )
109- expect ( onClose ) . not . toBeCalled ( )
105+ expect ( onSubmit ) . toBeCalledWith ( { all : [ ] , invalidData : [ ] , validData : [ ] } , file )
110106 } )
107+
108+ const errorToast = await screen . findAllByText ( ERROR_MESSAGE , undefined , { timeout : 5000 } )
109+
110+ expect ( onReject ) . toBeCalled ( )
111+ expect ( errorToast ?. [ 0 ] ) . toBeInTheDocument ( )
112+ expect ( onClose ) . not . toBeCalled ( )
111113 } )
112114
113115 test ( "Filters rows with required errors" , async ( ) => {
0 commit comments