1
0
Fork 0
blog/src/components/molecules/Web3Donation/InputGroup.test.tsx

22 lines
617 B
TypeScript
Raw Normal View History

2019-12-14 15:46:43 +01:00
import React from 'react'
import { render, fireEvent } from '@testing-library/react'
import InputGroup from './InputGroup'
2022-09-17 15:58:59 +02:00
const setAmount = jest.fn()
2019-12-14 15:46:43 +01:00
describe('InputGroup', () => {
it('renders without crashing', async () => {
const { container } = render(
2022-09-17 15:58:59 +02:00
<InputGroup amount="1" setAmount={setAmount} />
2019-12-14 15:46:43 +01:00
)
expect(container.firstChild).toBeInTheDocument()
const input = container.querySelector('input')
const button = container.querySelector('button')
2019-12-14 15:46:43 +01:00
fireEvent.change(input, { target: { value: '3' } })
fireEvent.click(button)
2022-09-17 15:58:59 +02:00
expect(setAmount).toHaveBeenCalled()
2019-12-14 15:46:43 +01:00
})
})