Skip to content

Commit

Permalink
fix: updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt561 committed Oct 3, 2024
1 parent 7125724 commit 749a4a6
Show file tree
Hide file tree
Showing 3 changed files with 552 additions and 871 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
import React from 'react';
import { fireEvent, screen } from '@testing-library/react-native';
import { renderScreen } from '../../../../../util/test/renderWithProvider';
import { backgroundState } from '../../../../../util/test/initial-root-state';
import { fireEvent } from '@testing-library/react-native';
import renderWithProvider from '../../../../../util/test/renderWithProvider';
import StakingBalance from './StakingBalance';
import { strings } from '../../../../../../locales/i18n';
import Routes from '../../../../../constants/navigation/Routes';
import { Image } from 'react-native';

function render(Component: React.ComponentType) {
return renderScreen(
Component,
{
name: 'Asset',
},
{
state: {
engine: {
backgroundState,
},
},
},
);
}
jest.mock('../../../../hooks/useIpfsGateway', () => jest.fn());

Image.getSize = jest.fn((_uri, success) => {
success(100, 100); // Mock successful response for ETH native Icon Image
});

const mockNavigate = jest.fn();

Expand All @@ -34,15 +24,17 @@ jest.mock('@react-navigation/native', () => {
};
});
describe('StakingBalance', () => {
beforeEach(() => jest.resetAllMocks());

it('render matches snapshot', () => {
render(StakingBalance);
expect(screen.toJSON()).toMatchSnapshot();
const { toJSON } = renderWithProvider(<StakingBalance />);
expect(toJSON()).toMatchSnapshot();
});

it('redirects to StakeInputView on stake button click', () => {
render(StakingBalance);
const { getByText } = renderWithProvider(<StakingBalance />);

fireEvent.press(screen.getByText(strings('stake.stake_more')));
fireEvent.press(getByText(strings('stake.stake_more')));

expect(mockNavigate).toHaveBeenCalledTimes(1);
expect(mockNavigate).toHaveBeenCalledWith('StakeScreens', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ exports[`StakingCta render matches snapshot 1`] = `
"fontWeight": "400",
"letterSpacing": 0,
"lineHeight": 22,
"paddingRight": 3,
}
}
>
Expand All @@ -68,7 +69,6 @@ exports[`StakingCta render matches snapshot 1`] = `
"fontWeight": "400",
"letterSpacing": 0,
"lineHeight": 22,
"paddingRight": 3,
}
}
>
Expand Down
Loading

0 comments on commit 749a4a6

Please sign in to comment.