Skip to content

Commit

Permalink
fix: historybox tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorency committed Dec 5, 2024
1 parent d10db53 commit 6f767da
Showing 1 changed file with 45 additions and 11 deletions.
56 changes: 45 additions & 11 deletions components/bank/components/__tests__/historyBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ mock.module('@/hooks', () => ({
],
},
}),
useGetFilteredTxAndSuccessfulProposals: () => ({
sendTxs: mockTransactions,
totalPages: 2,
isLoading: false,
isError: false,
}),
}));

describe('HistoryBox', () => {
Expand All @@ -38,12 +32,28 @@ describe('HistoryBox', () => {
});

test('renders correctly', () => {
renderWithChainProvider(<HistoryBox isLoading={false} address="address1" />);
renderWithChainProvider(
<HistoryBox
isLoading={false}
address="address1"
currentPage={1}
sendTxs={mockTransactions}
totalPages={2}
/>
);
expect(screen.getByText('Transaction History')).toBeInTheDocument();
});

test('displays transactions', () => {
renderWithChainProvider(<HistoryBox isLoading={false} address="address1" />);
renderWithChainProvider(
<HistoryBox
isLoading={false}
address="address1"
currentPage={1}
sendTxs={mockTransactions}
totalPages={2}
/>
);
expect(screen.getByText('Sent')).toBeInTheDocument();
expect(screen.getByText('Received')).toBeInTheDocument();

Expand All @@ -55,7 +65,15 @@ describe('HistoryBox', () => {
});

test('opens modal when clicking on a transaction', () => {
renderWithChainProvider(<HistoryBox isLoading={false} address="address1" />);
renderWithChainProvider(
<HistoryBox
isLoading={false}
address="address1"
currentPage={1}
sendTxs={mockTransactions}
totalPages={2}
/>
);

const transactionElement = screen.getByText('Sent').closest('div[role="button"]');

Expand All @@ -66,7 +84,15 @@ describe('HistoryBox', () => {
});

test('formats amount correctly', () => {
renderWithChainProvider(<HistoryBox isLoading={false} address="address1" />);
renderWithChainProvider(
<HistoryBox
isLoading={false}
address="address1"
currentPage={1}
sendTxs={mockTransactions}
totalPages={2}
/>
);
expect(screen.queryByText('-1.00QT TOKEN')).toBeInTheDocument(); // Send
expect(screen.queryByText('+2.00Q TOKEN')).toBeInTheDocument(); // Receive
expect(screen.queryByText('+3.00T TOKEN')).toBeInTheDocument(); // Mint
Expand All @@ -80,7 +106,15 @@ describe('HistoryBox', () => {
});

test('displays loading state', () => {
renderWithChainProvider(<HistoryBox isLoading={true} address="address1" />);
renderWithChainProvider(
<HistoryBox
isLoading={true}
address="address1"
currentPage={1}
sendTxs={mockTransactions}
totalPages={2}
/>
);
expect(screen.getByLabelText('skeleton')).toBeInTheDocument();
});
});

0 comments on commit 6f767da

Please sign in to comment.