-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add correct getBalance implementation for cardano add getBalance test change provider-entity address parameter for getBalance since cardano always return full wallet balance
- Loading branch information
1 parent
a932492
commit b0886a3
Showing
4 changed files
with
34 additions
and
9 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,28 @@ | ||
import { BalanceFetchError } from '@/errors/balance-fetch-error'; | ||
import { describe, expect, it, vi } from 'vitest'; | ||
import { getBalance } from './getBalance'; | ||
|
||
describe('Get balance use case', () => { | ||
const cardanoMockedAPI = { | ||
getBalance: vi.fn().mockResolvedValue('00'), | ||
getUsedAddresses: vi.fn(), | ||
getUnusedAddresses: vi.fn(), | ||
} | ||
|
||
const cardanoMockedInvalidAPI = { | ||
getBalance: async () => { | ||
throw new Error('unknown error') | ||
}, | ||
getUsedAddresses: vi.fn(), | ||
getUnusedAddresses: vi.fn(), | ||
} | ||
|
||
it('should be able to throw error when api throws error', async () => { | ||
await expect(getBalance(cardanoMockedInvalidAPI)).rejects.toThrow(BalanceFetchError) | ||
}) | ||
|
||
it('shoud be able to return mocked free balance', async () => { | ||
const balance = await getBalance(cardanoMockedAPI) | ||
expect(balance.free).toEqual('00') | ||
}) | ||
}) |
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
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