Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kremalicious committed Nov 5, 2023
1 parent e6d5e50 commit d31feb1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 10 additions & 6 deletions src/features/Web3/components/Input/InputGroup.test.tsx
Original file line number Diff line number Diff line change
@@ -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()
})
})
3 changes: 1 addition & 2 deletions src/features/Web3/components/TokenSelect/TokenSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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 ? (
Expand Down

0 comments on commit d31feb1

Please sign in to comment.