diff --git a/README.md b/README.md index 6b3db7e..f9c9e22 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Prerequisites +## Getting Started You will first need to [create a new project](https://cloud.walletconnect.com/) in wallet connect and then copy the *project id*. Once you have the *project id*, create a `.env` file and add the following: @@ -18,12 +18,16 @@ Finally, start the application: ```bash npm run dev -# or -yarn dev -# or -pnpm dev -# or -bun dev ``` Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. + +## Testing + +To run the test, issue the following command: + +```bash +npm run test +``` + +It will run the test defined within the `__tests__` folder. \ No newline at end of file diff --git a/__tests__/send-token-form.test.tsx b/__tests__/send-token-form.test.tsx index 675b391..21175ee 100644 --- a/__tests__/send-token-form.test.tsx +++ b/__tests__/send-token-form.test.tsx @@ -2,21 +2,21 @@ * @jest-environment jsdom */ -import React from 'react'; -import { render, fireEvent } from '@testing-library/react'; -import SendTokenForm from '@/components/send-token-form/send-token-form'; +import React from "react"; +import { render, fireEvent } from "@testing-library/react"; +import SendTokenForm from "@/components/send-token-form/send-token-form"; -describe('SendTokenForm', () => { +describe("SendTokenForm", () => { const mockBalance = { data: { - formatted: '10', - symbol: 'ETH', + formatted: "10", + symbol: "ETH", }, }; const mockOnSendTransaction = jest.fn(); - it('renders form elements correctly', () => { + it("renders form elements correctly", () => { const { getByText, getByPlaceholderText } = render( { /> ); - expect(getByText('Send To')).toBeInTheDocument(); - expect(getByPlaceholderText('Enter 0x address')).toBeInTheDocument(); - expect(getByText('Amount')).toBeInTheDocument(); - expect(getByPlaceholderText('0.01')).toBeInTheDocument(); + expect(getByText("Send To")).toBeInTheDocument(); + expect(getByPlaceholderText("Enter 0x address")).toBeInTheDocument(); + expect(getByText("Amount")).toBeInTheDocument(); + expect(getByPlaceholderText("0.01")).toBeInTheDocument(); }); - it('disables button and shows processing text when isTransactionProcessing is true', () => { + it("disables button and shows processing text when isTransactionProcessing is true", () => { const { getByText } = render( { /> ); - expect(getByText('Processing...')).toBeInTheDocument(); + expect(getByText("Processing...")).toBeInTheDocument(); }); - it('calls onSendTransaction with form data on form submission', () => { + it("calls onSendTransaction with form data on form submission", () => { const { getByText, getByPlaceholderText } = render( { /> ); - const addressInput = getByPlaceholderText('Enter 0x address'); - const amountInput = getByPlaceholderText('0.01'); + const addressInput = getByPlaceholderText("Enter 0x address"); + const amountInput = getByPlaceholderText("0.01"); const sendButton = getByText(`Send ${mockBalance.data.symbol}`); - fireEvent.change(addressInput, { target: { value: '0x1234567890' } }); - fireEvent.change(amountInput, { target: { value: '0.01' } }); + fireEvent.change(addressInput, { target: { value: "0x1234567890" } }); + fireEvent.change(amountInput, { target: { value: "0.01" } }); fireEvent.submit(sendButton); expect(mockOnSendTransaction).toHaveBeenCalledWith(