Skip to content

Commit

Permalink
Update tests and jest snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Jul 3, 2024
1 parent 7df5861 commit 533c2fb
Show file tree
Hide file tree
Showing 11 changed files with 579 additions and 795 deletions.
415 changes: 88 additions & 327 deletions src/app/pages/AccountPage/__tests__/__snapshots__/index.test.tsx.snap

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/app/pages/AccountPage/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ describe('<AccountPage />', () => {
expect(balance).toHaveTextContent('-')
const balanceSummary = await screen.findByTestId('account-balance-summary')
expect(balanceSummary.textContent).toMatchSnapshot()
const tabs = await screen.findByRole('navigation')
expect(tabs.textContent).toMatchSnapshot()
})

it('should sum total balance without losing precision', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export const ActiveDelegationList = () => {
return (
<>
<StakeSubnavigation />
<Box pad="medium" background="background-front">
<Header>{t('delegations.activeDelegations', 'Active delegations')}</Header>
<DelegationList type="active" delegations={delegations ?? []} />
<Box as="section" data-testid="active-delegations">
<Box pad="medium" background="background-front">
<Header>{t('delegations.activeDelegations', 'Active delegations')}</Header>
<DelegationList type="active" delegations={delegations ?? []} />
</Box>
</Box>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export const DebondingDelegationList = () => {
return (
<>
<StakeSubnavigation />
<Box pad="medium" background="background-front">
<Header>{t('delegations.debondingDelegations', 'Debonding delegations')}</Header>
<DelegationList type="debonding" delegations={delegations ?? []} />
<Box as="section" data-testid="debonding-delegations">
<Box pad="medium" background="background-front">
<Header>{t('delegations.debondingDelegations', 'Debonding delegations')}</Header>
<DelegationList type="debonding" delegations={delegations ?? []} />
</Box>
</Box>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import { ActiveDelegationList } from '../ActiveDelegationList'
import { configureAppStore } from 'store/configureStore'
import { stakingActions } from 'app/state/staking'
import { ThemeProvider } from '../../../../../../styles/theme/ThemeProvider'
import { MemoryRouter } from 'react-router-dom'

const renderComponent = (store: any) =>
render(
<Provider store={store}>
<ThemeProvider>
<ActiveDelegationList />
<MemoryRouter>
<ActiveDelegationList />
</MemoryRouter>
</ThemeProvider>
</Provider>,
)
Expand All @@ -24,7 +27,7 @@ describe('<ActiveDelegationList />', () => {
})

it('should match snapshot', () => {
const component = renderComponent(store)
renderComponent(store)
act(() => {
store.dispatch(
stakingActions.updateDelegations({
Expand All @@ -49,7 +52,7 @@ describe('<ActiveDelegationList />', () => {
)
})

expect(component.baseElement).toMatchSnapshot()
expect(screen.getByTestId('active-delegations')).toMatchSnapshot()

expect(screen.getByText('7%')).toBeInTheDocument()
expect(screen.queryByText('7.000000000000001%')).not.toBeInTheDocument()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import { DebondingDelegationList } from '../DebondingDelegationList'
import { configureAppStore } from 'store/configureStore'
import { stakingActions } from 'app/state/staking'
import { ThemeProvider } from '../../../../../../styles/theme/ThemeProvider'
import { MemoryRouter } from 'react-router-dom'

const renderComponent = (store: any) =>
render(
<Provider store={store}>
<ThemeProvider>
<DebondingDelegationList />
<MemoryRouter>
<DebondingDelegationList />
</MemoryRouter>
</ThemeProvider>
</Provider>,
)
Expand Down Expand Up @@ -52,7 +55,7 @@ describe('<DebondingDelegationList />', () => {
)
})

expect(component.baseElement).toMatchSnapshot()
expect(screen.getByTestId('debonding-delegations')).toMatchSnapshot()
})

it('should expand and display the delegation on click', async () => {
Expand Down
Loading

0 comments on commit 533c2fb

Please sign in to comment.