Skip to content

Instantly share code, notes, and snippets.

@hboylan
Created June 21, 2021 19:46
Show Gist options
  • Save hboylan/f649c81d0108da082b4ba225d25cbe15 to your computer and use it in GitHub Desktop.
Save hboylan/f649c81d0108da082b4ba225d25cbe15 to your computer and use it in GitHub Desktop.
it('renders with type', () => {
render(<Button type="submit" />)
expect(screen.getByTestId('button')).toHaveAttribute('type', 'submit')
})
it('renders with click event', () => {
const onClick = jest.fn()
render(<Button onClick={onClick} />)
userEvent.click(screen.getByTestId('button'))
expect(onClick).toHaveBeenCalled()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment