mars-v2-frontend/__tests__/components/Account/AccountDetails.test.tsx
Bob van der Helm 65ee49a3cd
🌟 Add HLS Vault Modal (#595)
* 🌟 Add HLS Vault Modal

* 🛠️ Fix failing build

* fix: keep the selected accountId if its present int the url (#588)

* Link changelog (#589)

* env: update RPC endpoint

* feat: added changelog link to the footer version

* Refactor balances table (#590)

* env: update env.example after last sync

* tidy: refactored AccountBalancesTable

* fix: updated isCard to hideCard

* fix: do update the health on sliding the margin back to 0 (#593)

* fix: disable highlighting on non-expandable rows (#592)

* Healthfactor adjustments (#594)

* fix: do update the health on sliding the margin back to 0

* MP-3531: first updates on the health bars

* fix: added exponential function for health percentage

* fix: build fix

* tidy: refactor

* tidy: cleanup

* feat: added new curve

* fix: base set to 3.5

* env: version update

* 🌟 Add HLS Vault Modal

* Use `DisplayCurrency` in subtitle header

* 🔥Remove redundant component

---------

Co-authored-by: Linkie Link <linkielink.dev@gmail.com>
2023-10-30 12:47:52 +01:00

62 lines
1.8 KiB
TypeScript

import { render, screen } from '@testing-library/react'
import AccountDetails from 'components/Account/AccountDetails'
import useCurrentAccount from 'hooks/useCurrentAccount'
import useStore from 'store'
jest.mock('hooks/useCurrentAccount', () => jest.fn(() => null))
jest.mock('hooks/useHealthComputer', () =>
jest.fn(() => ({
health: 0,
})),
)
// AccountBalancesTable component has wallet provider dependency, so we mock it
jest.mock('components/Account/AccountBalancesTable', () => jest.fn(() => null))
const mockedUseCurrentAccount = useCurrentAccount as jest.Mock
const mockedAccounts: Account[] = [
{ id: '1', deposits: [], lends: [], debts: [], vaults: [], kind: 'default' },
{ id: '2', deposits: [], lends: [], debts: [], vaults: [], kind: 'default' },
]
jest.mock('hooks/useAccountId', () => jest.fn(() => '1'))
jest.mock('hooks/useAccounts', () =>
jest.fn(() => ({
data: mockedAccounts,
})),
)
jest.mock('hooks/useAccountIds', () =>
jest.fn(() => ({
data: ['1', '2'],
})),
)
jest.mock('hooks/useCurrentAccount', () => jest.fn(() => mockedAccounts[0]))
describe('<AccountDetails />', () => {
beforeAll(() => {
useStore.setState({
address: 'walletAddress',
accounts: mockedAccounts,
})
})
afterAll(() => {
useStore.clearState()
})
it('renders account details WHEN account is selected', () => {
mockedUseCurrentAccount.mockReturnValue(mockedAccounts)
render(<AccountDetails />)
const container = screen.queryByTestId('account-details')
expect(container).toBeInTheDocument()
})
it('does not render WHEN account is NOT selected', () => {
mockedUseCurrentAccount.mockReturnValue(null)
render(<AccountDetails />)
const container = screen.queryByTestId('account-details')
expect(container).not.toBeInTheDocument()
})
})