mars-v2-frontend/__tests__/components/Account/AccountDetails.test.tsx
Linkie Link b0b957a5b3
MP-3338: added highlight to changed data in AccountBalancesTable (#424)
* MP-3338: added highlight to changed data in AccountBalancesTable

# Conflicts:
#	src/components/Account/AccountBalancesTable.tsx

* tidy: refactor

* refactor accountBalancesTable components

* MP-3357: created the Intro component (#427)

* MP-3338: added highlight to changed data in AccountBalancesTable

* refactor accountBalancesTable components

* MP-3338: added highlight to changed data in AccountBalancesTable

* refactor accountBalancesTable components

* refactor accountBalancesTable components

* refactor accountBalancesTable components

* MP-3338: added highlight to changed data in AccountBalancesTable

* refactor accountBalancesTable components

* refactor accountBalancesTable components

* fix test

---------

Co-authored-by: Bob van der Helm <34470358+bobthebuidlr@users.noreply.github.com>
2023-09-06 09:17:57 +02:00

44 lines
1.3 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
describe('<AccountDetails />', () => {
beforeAll(() => {
useStore.setState({
address: 'walletAddress',
})
})
afterAll(() => {
useStore.clearState()
})
it('renders account details WHEN account is selected', () => {
mockedUseCurrentAccount.mockReturnValue({ id: 1 })
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()
})
})