1
0
mirror of https://github.com/kremalicious/blog.git synced 2025-02-14 21:10:25 +01:00
blog/src/features/Web3/components/Input/InputGroup.test.tsx
2023-11-05 18:57:53 +00:00

30 lines
956 B
TypeScript

import { fireEvent, render, screen } from '@testing-library/react'
import { describe, it, expect } from 'vitest'
import { InputGroup } from '.'
describe('InputGroup', () => {
it('renders without crashing', async () => {
render(<InputGroup isDisabled={false} error={undefined} />)
const input = await screen.findByRole('textbox')
const button = await screen.findByRole('button')
fireEvent.change(input, { target: { value: '3' } })
fireEvent.click(button)
})
it('renders disabled', async () => {
render(<InputGroup isDisabled={true} error={undefined} />)
const input = await screen.findByRole('textbox')
expect(input).toBeDefined()
expect(input.attributes.getNamedItem('disabled')).toBeDefined()
})
it('renders error', async () => {
render(<InputGroup isDisabled={false} error={'Hello Error'} />)
const errorItem = await screen.findByText('Hello Error')
expect(errorItem).toBeDefined()
})
})