1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-24 10:16:27 +02:00
blog/src/components/Sponsor/Web3Donation/InputGroup.test.tsx

40 lines
983 B
TypeScript

import { fireEvent, render, screen } from '@testing-library/react'
import { describe, it, expect, vi } from 'vitest'
import InputGroup from './InputGroup'
const setAmount = vi.fn()
describe('InputGroup', () => {
it('renders without crashing', async () => {
render(
<InputGroup
amount="1"
setAmount={setAmount}
isDisabled={false}
symbol="ETH"
/>
)
const input = await screen.findByRole('textbox')
const button = await screen.findByRole('button')
fireEvent.change(input, { target: { value: '3' } })
fireEvent.click(button)
expect(setAmount).toHaveBeenCalled()
})
it('renders disabled', async () => {
render(
<InputGroup
amount="1"
setAmount={setAmount}
isDisabled={true}
symbol="ETH"
/>
)
const input = await screen.findByRole('textbox')
expect(input).toBeDefined()
expect(input.attributes.getNamedItem('disabled')).toBeDefined()
})
})