From d31feb15c35daa8f13a30b2d5501402070f8a16e Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sun, 5 Nov 2023 18:57:53 +0000 Subject: [PATCH] cleanup --- .../Web3/components/Input/InputGroup.test.tsx | 16 ++++++++++------ .../Web3/components/TokenSelect/TokenSelect.tsx | 3 +-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/features/Web3/components/Input/InputGroup.test.tsx b/src/features/Web3/components/Input/InputGroup.test.tsx index c073ff85..7a04a7f2 100644 --- a/src/features/Web3/components/Input/InputGroup.test.tsx +++ b/src/features/Web3/components/Input/InputGroup.test.tsx @@ -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() + render() 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() + render() const input = await screen.findByRole('textbox') expect(input).toBeDefined() expect(input.attributes.getNamedItem('disabled')).toBeDefined() }) + + it('renders error', async () => { + render() + + const errorItem = await screen.findByText('Hello Error') + expect(errorItem).toBeDefined() + }) }) diff --git a/src/features/Web3/components/TokenSelect/TokenSelect.tsx b/src/features/Web3/components/TokenSelect/TokenSelect.tsx index c99db5ae..8d498f31 100644 --- a/src/features/Web3/components/TokenSelect/TokenSelect.tsx +++ b/src/features/Web3/components/TokenSelect/TokenSelect.tsx @@ -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 ? (