Skip to content

Commit

Permalink
fix: tests & refactor
Browse files Browse the repository at this point in the history
Refactor GroupDetailsForm, GroupPolicyForm & MemberInfoForm so tests are
passing without warnings.
  • Loading branch information
fmorency committed Jan 6, 2025
1 parent 7cc9b9f commit 6b4432d
Show file tree
Hide file tree
Showing 15 changed files with 628 additions and 600 deletions.
1 change: 0 additions & 1 deletion components/bank/components/__tests__/historyBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ describe('HistoryBox', () => {
totalPages={2}
/>
);
expect(screen.getByText('Transaction History')).toBeInTheDocument();
});

test('displays transactions', () => {
Expand Down
6 changes: 2 additions & 4 deletions components/bank/components/__tests__/tokenList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('TokenList', () => {
pageSize={1}
/>
);
expect(screen.getByText('Your Assets')).toBeInTheDocument();
expect(screen.getByText('utoken1')).toBeInTheDocument();
});

test('displays loading skeleton when isLoading is true', () => {
Expand Down Expand Up @@ -111,11 +111,9 @@ describe('TokenList', () => {
refetchHistory={jest.fn()}
address={''}
pageSize={1}
searchTerm={'Token 1'}
/>
);
const searchInput = screen.getByPlaceholderText('Search for a token...');
fireEvent.change(searchInput, { target: { value: 'Token 1' } });

expect(screen.getByText('Token 1')).toBeInTheDocument();
expect(screen.queryByText('Token 2')).not.toBeInTheDocument();
});
Expand Down
19 changes: 7 additions & 12 deletions components/factory/components/__tests__/MyDenoms.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { screen, cleanup, fireEvent, waitFor } from '@testing-library/react';
import DenomList from '@/components/factory/components/DenomList';
import matchers from '@testing-library/jest-dom/matchers';
import { renderWithChainProvider } from '@/tests/render';
import { mockDenom, mockMfxDenom } from '@/tests/mock';
import { mockDenom, mockDenom2, mockMfxDenom } from '@/tests/mock';

expect.extend(matchers);

Expand Down Expand Up @@ -40,11 +40,12 @@ const renderWithProps = (props = {}) => {
isError: null,
refetchDenoms: jest.fn(),
address: '',
pageSize: 2,
};
return renderWithChainProvider(<DenomList {...defaultProps} {...props} />);
};

const allDenoms = [mockDenom, mockMfxDenom];
const allDenoms = [mockDenom, mockDenom2];

describe('MyDenoms', () => {
afterEach(() => {
Expand All @@ -64,7 +65,7 @@ describe('MyDenoms', () => {

test('renders denoms correctly', () => {
renderWithProps({ denoms: allDenoms });
const mfxs = screen.getAllByText('MFX');
const mfxs = screen.getAllByText('TEST2');
mfxs.forEach(element => {
expect(element).toBeInTheDocument();
});
Expand All @@ -76,12 +77,9 @@ describe('MyDenoms', () => {
});

test('filters denoms based on search query', async () => {
renderWithProps({ denoms: allDenoms });
const searchInput = screen.getByPlaceholderText('Search for a token...');
fireEvent.change(searchInput, { target: { value: 'MFX' } });

renderWithProps({ denoms: allDenoms, searchTerm: 'TEST2' });
await waitFor(() => {
const tests = screen.getAllByText('MFX');
const tests = screen.getAllByText('TEST2');
tests.forEach(element => {
expect(element).toBeInTheDocument();
});
Expand All @@ -91,10 +89,7 @@ describe('MyDenoms', () => {
});

test("displays 'No tokens found' when no denoms match search query", async () => {
renderWithProps({ denoms: allDenoms });

const searchInput = screen.getByPlaceholderText('Search for a token...');
fireEvent.change(searchInput, { target: { value: 'Nonexistent Denom' } });
renderWithProps({ denoms: allDenoms, searchTerm: 'Nonexistent Denom' });
await waitFor(() => {
expect(screen.queryByText('TEST')).not.toBeInTheDocument();
});
Expand Down
1 change: 1 addition & 0 deletions components/factory/forms/__tests__/BurnForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const mockProps = {
address: 'cosmos1address',
refetch: jest.fn(),
balance: '1000000',
totalSupply: '1000000',
};

function renderWithProps(props = {}) {
Expand Down
1 change: 1 addition & 0 deletions components/factory/forms/__tests__/MintForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const mockProps = {
address: 'cosmos1address',
refetch: jest.fn(),
balance: '1000000',
totalSupply: '1000000',
};

function renderWithProps(props = {}) {
Expand Down
2 changes: 1 addition & 1 deletion components/groups/components/__tests__/myGroups.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('YourGroups Component', () => {

test('renders empty group state correctly', () => {
renderWithChainProvider(<YourGroups {...{ ...mockProps, groups: { groups: [] } }} />);
expect(screen.getByText('My groups')).toBeInTheDocument();
expect(screen.getByText('Groups')).toBeInTheDocument();
});

test('renders loading state correctly', () => {
Expand Down
Loading

0 comments on commit 6b4432d

Please sign in to comment.