mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-22 01:46:51 +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 { fireEvent, render, screen } from '@testing-library/react'
|
||||||
import { describe, it, expect, vi } from 'vitest'
|
import { describe, it, expect } from 'vitest'
|
||||||
import { InputGroup } from '.'
|
import { InputGroup } from '.'
|
||||||
|
|
||||||
const setAmount = vi.fn()
|
|
||||||
|
|
||||||
describe('InputGroup', () => {
|
describe('InputGroup', () => {
|
||||||
it('renders without crashing', async () => {
|
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 input = await screen.findByRole('textbox')
|
||||||
const button = await screen.findByRole('button')
|
const button = await screen.findByRole('button')
|
||||||
fireEvent.change(input, { target: { value: '3' } })
|
fireEvent.change(input, { target: { value: '3' } })
|
||||||
fireEvent.click(button)
|
fireEvent.click(button)
|
||||||
expect(setAmount).toHaveBeenCalled()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders disabled', async () => {
|
it('renders disabled', async () => {
|
||||||
render(<InputGroup amount="1" setAmount={setAmount} isDisabled={true} />)
|
render(<InputGroup isDisabled={true} error={undefined} />)
|
||||||
|
|
||||||
const input = await screen.findByRole('textbox')
|
const input = await screen.findByRole('textbox')
|
||||||
expect(input).toBeDefined()
|
expect(input).toBeDefined()
|
||||||
expect(input.attributes.getNamedItem('disabled')).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}`) {
|
function handleValueChange(value: `0x${string}`) {
|
||||||
const token = tokens?.find((token) => token.address === value)
|
const token = tokens?.find((token) => token.address === value)
|
||||||
if (!token) return
|
if (!token) return
|
||||||
|
|
||||||
$setSelectedToken(token)
|
$setSelectedToken(token)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,9 +32,7 @@ export function TokenSelect() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedToken?.address || !tokens || !tokens?.length) return
|
if (selectedToken?.address || !tokens || !tokens?.length) return
|
||||||
|
|
||||||
console.log(tokens)
|
|
||||||
handleValueChange('0x0')
|
handleValueChange('0x0')
|
||||||
console.log('auto-select 0x0')
|
|
||||||
}, [tokens, selectedToken])
|
}, [tokens, selectedToken])
|
||||||
|
|
||||||
return tokens && address ? (
|
return tokens && address ? (
|
||||||
|
Loading…
Reference in New Issue
Block a user