Skip to content

Instantly share code, notes, and snippets.

@nedgrady
Created November 19, 2024 00:03
Show Gist options
  • Save nedgrady/fd685656d697ca4e87f9bd7da33068ea to your computer and use it in GitHub Desktop.
Save nedgrady/fd685656d697ca4e87f9bd7da33068ea to your computer and use it in GitHub Desktop.
test("When the 'cancel' button is clicked, onClose is called", () => {
render(
<CustomModal
onClose={reason => {
expect(reason).toBe("clicked cancel")
}}
/>,
)
const button = screen.getByRole("button", { name: /Cancel/i })
userEvent.click(button)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment