Skip to content

Commit 4d3951f

Browse files
committed
Add a test to check that modal closes after submit
1 parent db781cd commit 4d3951f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/steps/ValidationStep/tests/ValidationStep.test.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,35 @@ describe("Validation step tests", () => {
4848
})
4949
})
5050

51+
test("Submit data without returning promise", async () => {
52+
const onSuccess = jest.fn()
53+
const onSubmit = jest.fn(() => {
54+
onSuccess()
55+
})
56+
const onClose = jest.fn()
57+
render(
58+
<Providers theme={defaultTheme} rsiValues={{ ...mockValues, onSubmit, onClose }}>
59+
<ModalWrapper isOpen={true} onClose={() => {}}>
60+
<ValidationStep initialData={[]} file={file} />
61+
</ModalWrapper>
62+
</Providers>,
63+
)
64+
65+
const finishButton = screen.getByRole("button", {
66+
name: "Confirm",
67+
})
68+
69+
await userEvent.click(finishButton)
70+
71+
await waitFor(() => {
72+
expect(onSubmit).toBeCalledWith({ all: [], invalidData: [], validData: [] }, file)
73+
})
74+
await waitFor(() => {
75+
expect(onSuccess).toBeCalled()
76+
expect(onClose).toBeCalled()
77+
})
78+
})
79+
5180
test("Submit data with a successful async return", async () => {
5281
const onSuccess = jest.fn()
5382
const onSubmit = jest.fn(async (): Promise<void> => {

0 commit comments

Comments
 (0)