-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/components/cards/StakingOpportunitesCard/FilteredTags/FilteredTags.tsx
- Loading branch information
Showing
6 changed files
with
100 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Run tests | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- release | ||
pull_request: | ||
branches: | ||
- master | ||
- release | ||
jobs: | ||
run_tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: get code | ||
uses: actions/checkout@v3 | ||
- name: setup npm | ||
uses: actions/setup-node@v2 | ||
- name: install bun | ||
uses: oven-sh/setup-bun@v1 | ||
- name: install dependencies | ||
run: bun install | ||
- name: run tests | ||
run: bun run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { fireEvent, render, waitFor } from '@testing-library/react' | ||
import { ListModal } from '../../components/modals/ListModal/ListModal' | ||
import jest from 'jest-mock' | ||
|
||
const mockGetItems = jest.fn().mockResolvedValue([]) | ||
|
||
describe('ListModal Component', () => { | ||
it('renders ListModal component correctly', () => { | ||
const { getByText, getByPlaceholderText } = render( | ||
<ListModal getItems={mockGetItems} isOpen={true} setIsOpen={() => {}} title="Test Modal" RenderItem={() => <div>Mock Item</div>} />, | ||
) | ||
|
||
expect(getByText('Test Modal')).toBeInTheDocument() | ||
expect(getByPlaceholderText('Search...')).toBeInTheDocument() | ||
}) | ||
|
||
it('handles search functionality', async () => { | ||
const { getByPlaceholderText, getByText } = render( | ||
<ListModal getItems={mockGetItems} isOpen={true} setIsOpen={() => {}} title="Test Modal" RenderItem={() => <div>Mock Item</div>} />, | ||
) | ||
|
||
const searchInput = getByPlaceholderText('Search...') | ||
|
||
fireEvent.change(searchInput, { target: { value: 'test search' } }) | ||
|
||
await waitFor(() => { | ||
expect(mockGetItems).toHaveBeenCalledWith({ | ||
offset: 0, | ||
limit: 15, | ||
search: 'test search', | ||
}) | ||
}) | ||
|
||
expect(getByText('Test Modal')).toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { fireEvent, render } from '@testing-library/react' | ||
import { SwapButton } from '../../components/buttons/SwapButton/SwapButton' | ||
import jest from 'jest-mock' | ||
import { buttonText, ButtonType } from '../../components/buttons/SwapButton/constants' | ||
|
||
describe('SwapButton component', () => { | ||
const mockProps = { | ||
swapState: { | ||
isLoading: false, | ||
from: { | ||
amount: 0, | ||
}, | ||
}, | ||
isConnected: true, | ||
onClick: jest.fn(), | ||
} | ||
|
||
test('renders SwapButton correctly', () => { | ||
const { getByText } = render(<SwapButton {...mockProps} />) | ||
expect(getByText(buttonText[ButtonType.ENTER_AMOUNT])).toBeInTheDocument() | ||
}) | ||
|
||
test('triggers onClick function when button is clicked', () => { | ||
const { getByText } = render(<SwapButton {...mockProps} />) | ||
const button = getByText(buttonText[ButtonType.ENTER_AMOUNT]) | ||
fireEvent.click(button) | ||
expect(mockProps.onClick).toHaveBeenCalledTimes(1) | ||
}) | ||
|
||
test('render connect wallet button', () => { | ||
mockProps.isConnected = false | ||
const { getByText } = render(<SwapButton {...mockProps} />) | ||
expect(getByText(buttonText[ButtonType.CONNECT_WALLET])).toBeInTheDocument() | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters