mirror of
https://github.com/kremalicious/blog.git
synced 2024-12-22 09:13:35 +01:00
cleanup
This commit is contained in:
parent
e6d5e504b0
commit
d31feb15c3
@ -1,25 +1,29 @@
|
||||
import { fireEvent, render, screen } from '@testing-library/react'
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { InputGroup } from '.'
|
||||
|
||||
const setAmount = vi.fn()
|
||||
|
||||
describe('InputGroup', () => {
|
||||
it('renders without crashing', async () => {
|
||||
render(<InputGroup amount="1" setAmount={setAmount} isDisabled={false} />)
|
||||
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)
|
||||
expect(setAmount).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('renders disabled', async () => {
|
||||
render(<InputGroup amount="1" setAmount={setAmount} isDisabled={true} />)
|
||||
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()
|
||||
})
|
||||
})
|
||||
|
@ -23,6 +23,7 @@ export function TokenSelect() {
|
||||
function handleValueChange(value: `0x${string}`) {
|
||||
const token = tokens?.find((token) => token.address === value)
|
||||
if (!token) return
|
||||
|
||||
$setSelectedToken(token)
|
||||
}
|
||||
|
||||
@ -31,9 +32,7 @@ export function TokenSelect() {
|
||||
useEffect(() => {
|
||||
if (selectedToken?.address || !tokens || !tokens?.length) return
|
||||
|
||||
console.log(tokens)
|
||||
handleValueChange('0x0')
|
||||
console.log('auto-select 0x0')
|
||||
}, [tokens, selectedToken])
|
||||
|
||||
return tokens && address ? (
|
||||
|
Loading…
Reference in New Issue
Block a user