Skip to content

Commit

Permalink
chore: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
rabyyuson committed Apr 11, 2024
1 parent 5d1c76b commit 8636e38
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:

Expand All @@ -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.
36 changes: 18 additions & 18 deletions __tests__/send-token-form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<SendTokenForm
balance={mockBalance}
Expand All @@ -25,13 +25,13 @@ describe('SendTokenForm', () => {
/>
);

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(
<SendTokenForm
balance={mockBalance}
Expand All @@ -40,10 +40,10 @@ describe('SendTokenForm', () => {
/>
);

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(
<SendTokenForm
balance={mockBalance}
Expand All @@ -52,12 +52,12 @@ describe('SendTokenForm', () => {
/>
);

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(
Expand Down

0 comments on commit 8636e38

Please sign in to comment.