Skip to content

Commit c264c90

Browse files
committed
Hide required token if skip if balance
1 parent 403d496 commit c264c90

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/components/Views/confirmations/components/modals/pay-with-modal/pay-with-modal.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,20 @@ describe('PayWithModal', () => {
201201
expect(queryByText('Test Token 4')).toBeNull();
202202
});
203203

204+
it('does not render token with zero balance if required token and skipIfBalance is true', async () => {
205+
useTransactionPayRequiredTokensMock.mockReturnValue([
206+
{
207+
address: '0x234' as Hex,
208+
chainId: CHAIN_ID_1_MOCK,
209+
skipIfBalance: true,
210+
},
211+
] as TransactionPayRequiredToken[]);
212+
213+
const { queryByText } = render();
214+
215+
expect(queryByText('Test Token 2')).toBeNull();
216+
});
217+
204218
describe('on token select', () => {
205219
it('sets pay asset', async () => {
206220
const { getByText } = render();

app/components/Views/confirmations/components/modals/pay-with-modal/pay-with-modal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export function PayWithModal() {
5555
const isRequiredToken = requiredTokens.some(
5656
(t) =>
5757
t.address.toLowerCase() === token.address.toLowerCase() &&
58-
t.chainId === token.chainId,
58+
t.chainId === token.chainId &&
59+
!t.skipIfBalance,
5960
);
6061

6162
if (isRequiredToken) {

0 commit comments

Comments
 (0)