2023-05-08 14:47:19 +00:00
|
|
|
import { render, screen } from '@testing-library/react'
|
2023-05-16 10:39:52 +00:00
|
|
|
import * as rrd from 'react-router-dom'
|
2023-05-08 14:47:19 +00:00
|
|
|
|
|
|
|
import AccountDetails from 'components/Account/AccountDetails'
|
|
|
|
|
2023-05-16 10:39:52 +00:00
|
|
|
jest.mock('react-router-dom')
|
|
|
|
const mockedUseParams = rrd.useParams as jest.Mock
|
2023-05-08 14:47:19 +00:00
|
|
|
|
|
|
|
describe('<AccountDetails />', () => {
|
|
|
|
afterAll(() => {
|
|
|
|
mockedUseParams.mockRestore()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('renders account details WHEN accountId specified in the params', () => {
|
|
|
|
mockedUseParams.mockReturnValue({ accountId: 1 })
|
|
|
|
render(<AccountDetails />)
|
|
|
|
|
|
|
|
const container = screen.queryByTestId('account-details')
|
|
|
|
expect(container).toBeInTheDocument()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('does not render WHEN accountId is NOT specified in the params', () => {
|
|
|
|
mockedUseParams.mockReturnValue({ accountId: null })
|
|
|
|
render(<AccountDetails />)
|
|
|
|
|
|
|
|
const container = screen.queryByTestId('account-details')
|
|
|
|
expect(container).not.toBeInTheDocument()
|
|
|
|
})
|
|
|
|
})
|