Skip to content

Commit

Permalink
chore: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gambinish committed Oct 23, 2024
1 parent 0d00f62 commit 784c39f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Engine from '../../../../core/Engine';
import { selectTokenSortConfig } from '../../../../selectors/preferencesController';
import { selectCurrentCurrency } from '../../../../selectors/currencyRateController';

// Mock useSelector and useTheme
jest.mock('react-redux', () => ({
useSelector: jest.fn(),
}));
Expand All @@ -24,17 +23,17 @@ jest.mock('../../../../core/Engine', () => ({
}));

jest.mock('@react-navigation/native', () => {
const actualNav = jest.requireActual('@react-navigation/native');
const reactNavigationModule = jest.requireActual('@react-navigation/native');
return {
...actualNav,
...reactNavigationModule,
useNavigation: () => ({
navigate: jest.fn(),
}),
};
});

jest.mock('react-native-safe-area-context', () => {
// using disting digits for mock rects to make sure they are not mixed up
// copied from BottomSheetDialog.test.tsx
const inset = { top: 1, right: 2, bottom: 3, left: 4 };
const frame = { width: 5, height: 6, x: 7, y: 8 };
return {
Expand Down
8 changes: 2 additions & 6 deletions app/components/UI/Tokens/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ describe('Tokens', () => {
mockNavigate.mockClear();
mockPush.mockClear();
});

it('should render correctly', () => {
const { toJSON } = renderComponent(initialState);
expect(toJSON()).toMatchSnapshot();
});

it('should hide zero balance tokens when setting is on', async () => {
const { toJSON, getByText, queryByText } = renderComponent(initialState);
// ETH and BAT should display

expect(getByText('Ethereum')).toBeDefined();
await waitFor(() => expect(getByText('Bat')).toBeDefined());
Expand All @@ -204,7 +204,6 @@ describe('Tokens', () => {
expect(getByText('Ethereum')).toBeDefined();
await waitFor(() => expect(getByText('Bat')).toBeDefined());
expect(getByText('Link')).toBeDefined();
// All three should display
expect(toJSON()).toMatchSnapshot();
});

Expand Down Expand Up @@ -301,8 +300,6 @@ describe('Tokens', () => {
it('should refresh tokens and call necessary controllers', async () => {
const { getByTestId } = renderComponent(initialState);

// fireEvent.press(getByTestId(WalletViewSelectorsIDs.TOKENS_CONTAINER));
// Simulate a scroll event
fireEvent.scroll(
getByTestId(WalletViewSelectorsIDs.TOKENS_CONTAINER_LIST),
{
Expand All @@ -314,7 +311,6 @@ describe('Tokens', () => {
},
);

// Simulate the refresh control being triggered
fireEvent(
getByTestId(WalletViewSelectorsIDs.TOKENS_CONTAINER_LIST),
'refresh',
Expand Down Expand Up @@ -342,7 +338,7 @@ describe('Tokens', () => {
it('triggers bottom sheet when sort controls are pressed', async () => {
const { getByText } = renderComponent(initialState);

await fireEvent.press(getByText('Sort by')); // Long press to trigger remove
await fireEvent.press(getByText('Sort by'));

await waitFor(() => {
expect(createTokensBottomSheetNavDetails).toHaveBeenCalledWith({});
Expand Down

0 comments on commit 784c39f

Please sign in to comment.