ea614997a7
* feat: do not redirect to wallet on portfolio page * fix: use connected wallet for AccountMenu * fix: fixed ghost AccountDetails * feat: created ShareBar and share functionality * fix: don’t show shareBar if no address is present * fix: stupid 'next/navigation' * tidy: format * fix: fixed tests * ✨ routing and pages for HLS (#538) * 🐛 use useAccountIds * fix: fixed the tests * fix: accountIds is now a suspense --------- Co-authored-by: Bob van der Helm <34470358+bobthebuidlr@users.noreply.github.com>
62 lines
1.7 KiB
TypeScript
62 lines
1.7 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 = [
|
|
{ id: '1', deposits: [], lends: [], debts: [], vaults: [] },
|
|
{ id: '2', deposits: [], lends: [], debts: [], vaults: [] },
|
|
]
|
|
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()
|
|
})
|
|
})
|