Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
infiniteflower committed Feb 5, 2025
1 parent 1e6f12a commit 848122f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/bridge-controller/src/utils/balance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,27 @@ describe('balance', () => {
),
).toBe(false);
});

it('should return false if source token balance is undefined', async () => {
const mockBalanceOf = jest.fn().mockResolvedValueOnce(undefined);
(Contract as unknown as jest.Mock).mockImplementation(() => ({
balanceOf: mockBalanceOf,
}));

expect(
await balanceUtils.hasSufficientBalance(
global.ethereumProvider,
'0x141d32a89a1e0a5ef360034a2f60a4b917c18838',
'0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
'10000000000000000000',
'0x1',
),
).toBe(false);

expect(mockBalanceOf).toHaveBeenCalledTimes(1);
expect(mockBalanceOf).toHaveBeenCalledWith(
'0x141d32a89a1e0a5ef360034a2f60a4b917c18838',
);
});
});
});

0 comments on commit 848122f

Please sign in to comment.