mars-v2-frontend/__tests__/components/Modals/vault/VaultBorrowings.test.tsx
Bob van der Helm 999bad4059
Mp 2880 modifying farm position (#272)
* added correct resolving of account positions

* solve rendering bug for lp amount

* bugfix: add slippage to minlpamount

* fix DisplayCurrency to accept only BNCoin

* bugfix: remove prices from store

* add basic depostied vaults table

* Farm: Added deposited table

* finish deposited table, remove featured vaults:

* enable deposit more for vaults

* use controller for vault modal

* small fixes and polishing of add deposit

* fix tests, run format

* removed empty deposited table

---------

Co-authored-by: Linkie Link <linkielink.dev@gmail.com>
2023-06-29 13:12:11 +02:00

89 lines
2.0 KiB
TypeScript

import { render } from '@testing-library/react'
import { ASSETS } from 'constants/assets'
import { BN } from 'utils/helpers'
import useStore from 'store'
import DisplayCurrency from 'components/DisplayCurrency'
import VaultBorrowings, { VaultBorrowingsProps } from 'components/Modals/Vault/VaultBorrowings'
import { TESTNET_VAULTS_META_DATA } from 'constants/vaults'
import { BNCoin } from 'types/classes/BNCoin'
jest.mock('hooks/usePrices', () =>
jest.fn(() => ({
data: [],
})),
)
jest.mock('hooks/usePrice', () => jest.fn(() => '1'))
jest.mock('hooks/useMarketAssets', () =>
jest.fn(() => ({
data: [],
})),
)
jest.mock('hooks/broadcast/useDepositVault', () => jest.fn(() => ({ actions: [] })))
jest.mock('components/DisplayCurrency')
const mockedDisplayCurrency = jest
.mocked(DisplayCurrency)
.mockImplementation(() => <div>Display currency</div>)
const mockedVault: Vault = {
...TESTNET_VAULTS_META_DATA[0],
apy: 0,
ltv: {
liq: 0.2,
max: 0.1,
},
cap: {
denom: 'test',
max: BN(10),
used: BN(2),
},
}
describe('<VaultBorrowings />', () => {
const defaultProps: VaultBorrowingsProps = {
primaryAsset: ASSETS[0],
secondaryAsset: ASSETS[1],
primaryAmount: BN(0),
secondaryAmount: BN(0),
account: {
id: 'test',
deposits: [],
debts: [],
vaults: [],
lends: [],
},
vault: mockedVault,
borrowings: [],
deposits: [],
onChangeBorrowings: jest.fn(),
}
beforeAll(() => {
useStore.setState({
baseCurrency: ASSETS[0],
})
})
afterAll(() => {
useStore.clearState()
mockedDisplayCurrency.mockClear()
})
it('should render', () => {
const { container } = render(<VaultBorrowings {...defaultProps} />)
expect(container).toBeInTheDocument()
})
it('should render DisplayCurrency correctly', () => {
expect(mockedDisplayCurrency).toHaveBeenCalledTimes(1)
expect(mockedDisplayCurrency).toHaveBeenCalledWith(
{ coin: new BNCoin({ denom: 'uosmo', amount: '0' }) },
expect.anything(),
)
})
})