mars-v2-frontend/__tests__/components/Modals/vault/VaultBorrowings.test.tsx
Bob van der Helm 7b5d4c3255
Mp 2546 borrow asset modal (#255)
* Refactor Modal folder and setup basic addassetsmodal

* basic tables

* Update basic logic

* small fixes

* Update closing for modals

* fix slider update bug and set borrowing subtitle

* fix store

* add missing dependency

* fix tests for VaultBorrowings

* Add DisplayCurrency test for VaultBorrowings

* trigger updated

* update borrowModal import path

* update imports for modals

* updating paths again

* update structure of modals directory

* fix all file naming and relative imports

* fix icon spacing button and jest.mocked import

* fix icon classes for button

* change Map to array and add BNCoin

* add AssetImage

* update logic for selecting borrow denoms
2023-06-15 13:00:46 +02:00

70 lines
1.7 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'
jest.mock('hooks/usePrices', () =>
jest.fn(() => ({
data: [],
})),
)
jest.mock('hooks/usePrice', () => jest.fn(() => '1'))
jest.mock('hooks/useMarketAssets', () =>
jest.fn(() => ({
data: [],
})),
)
jest.mock('components/DisplayCurrency')
const mockedDisplayCurrency = jest
.mocked(DisplayCurrency)
.mockImplementation(() => <div>Display currency</div>)
describe('<VaultBorrowings />', () => {
const defaultProps: VaultBorrowingsProps = {
primaryAsset: ASSETS[0],
secondaryAsset: ASSETS[1],
primaryAmount: BN(0),
secondaryAmount: BN(0),
account: {
id: 'test',
deposits: [],
debts: [],
vaults: [],
lends: [],
},
borrowings: [],
onChangeBorrowings: jest.fn(),
}
beforeAll(() => {
useStore.setState({
baseCurrency: ASSETS[0],
selectedBorrowDenoms: [ASSETS[1].denom],
})
})
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: { denom: 'uosmo', amount: '0' } },
expect.anything(),
)
})
})