Skip to content

Instantly share code, notes, and snippets.

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