Skip to content

Commit

Permalink
fix: Mock initial state that PortfolioBalance component needs
Browse files Browse the repository at this point in the history
  • Loading branch information
gambinish committed Oct 16, 2024
1 parent fe21f40 commit a5d8b71
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions app/components/Views/Wallet/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { backgroundState } from '../../../util/test/initial-root-state';
import { createMockAccountsControllerState } from '../../../util/test/accountsControllerTestUtils';
import { WalletViewSelectorsIDs } from '../../../../e2e/selectors/wallet/WalletView.selectors';
import { CommonSelectorsIDs } from '../../../../e2e/selectors/Common.selectors';
import { BN } from 'ethereumjs-util';

const MOCK_ADDRESS = '0xc4955c0d639d99699bfd7ec54d9fafee40e4d272';

Expand All @@ -30,6 +31,9 @@ jest.mock('../../../core/Engine', () => ({
},
},
},
TokensController: {
ignoreTokens: jest.fn(() => Promise.resolve()),
},
TokenRatesController: {
poll: jest.fn(),
},
Expand Down Expand Up @@ -83,6 +87,60 @@ const mockInitialState = {
AccountsController: {
...MOCK_ACCOUNTS_CONTROLLER_STATE,
},
TokensController: {
tokens: [
{
name: 'Ethereum',
symbol: 'ETH',
address: '0x0',
decimals: 18,
isETH: true,

balanceFiat: '< $0.01',
iconUrl: '',
},
{
name: 'Bat',
symbol: 'BAT',
address: '0x01',
decimals: 18,
balanceFiat: '$0',
iconUrl: '',
},
{
name: 'Link',
symbol: 'LINK',
address: '0x02',
decimals: 18,
balanceFiat: '$0',
iconUrl: '',
},
],
},
TokenRatesController: {
marketData: {
'0x1': {
'0x0': { price: 0.005 },
'0x01': { price: 0.005 },
'0x02': { price: 0.005 },
},
},
},
CurrencyRateController: {
currentCurrency: 'USD',
currencyRates: {
ETH: {
conversionRate: 1,
},
},
},
TokenBalancesController: {
contractBalances: {
'0x00': new BN(2).toString(),
'0x01': new BN(2).toString(),
'0x02': new BN(0).toString(),
},
},
},
},
};
Expand All @@ -94,6 +152,20 @@ jest.mock('react-redux', () => ({
.mockImplementation((callback) => callback(mockInitialState)),
}));

const mockNavigate = jest.fn();
const mockPush = jest.fn();

jest.mock('@react-navigation/native', () => {
const actualReactNavigation = jest.requireActual('@react-navigation/native');
return {
...actualReactNavigation,
useNavigation: () => ({
navigate: mockNavigate,
push: mockPush,
}),
};
});

jest.mock('react-native-scrollable-tab-view', () => {
const ScrollableTabViewMock = jest
.fn()
Expand Down

0 comments on commit a5d8b71

Please sign in to comment.