Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import MoneyAddMoneySheet from './MoneyAddMoneySheet';
import { MoneyAddMoneySheetTestIds } from './MoneyAddMoneySheet.testIds';
import { useMusdConversionFlowData } from '../../../Earn/hooks/useMusdConversionFlowData';
import { useRampNavigation } from '../../../Ramp/hooks/useRampNavigation';
import { useMusdBalance } from '../../../Earn/hooks/useMusdBalance';
import useMoneyAccountBalance from '../../hooks/useMoneyAccountBalance';
import { useMoneyAccountDeposit } from '../../hooks/useMoneyAccount';
import {
MUSD_CONVERSION_DEFAULT_CHAIN_ID,
Expand Down Expand Up @@ -38,8 +38,9 @@ jest.mock('../../../Ramp/hooks/useRampNavigation', () => ({
useRampNavigation: jest.fn(),
}));

jest.mock('../../../Earn/hooks/useMusdBalance', () => ({
useMusdBalance: jest.fn(),
jest.mock('../../hooks/useMoneyAccountBalance', () => ({
__esModule: true,
default: jest.fn(),
}));

jest.mock('../../hooks/useMoneyAccount', () => ({
Expand Down Expand Up @@ -86,8 +87,8 @@ describe('MoneyAddMoneySheet', () => {
(useRampNavigation as jest.Mock).mockReturnValue({
goToBuy: mockGoToBuy,
});
(useMusdBalance as jest.Mock).mockReturnValue({
fiatBalanceAggregatedFormatted: '$1,203.89',
(useMoneyAccountBalance as jest.Mock).mockReturnValue({
totalFiatFormatted: '$1,203.89',
});
(useMoneyAccountDeposit as jest.Mock).mockReturnValue({
initiateDeposit: mockInitiateDeposit,
Expand All @@ -110,17 +111,17 @@ describe('MoneyAddMoneySheet', () => {
});

it('preserves the locale fiat prefix in the Move mUSD row', () => {
(useMusdBalance as jest.Mock).mockReturnValue({
fiatBalanceAggregatedFormatted: 'CA$1,500.00',
(useMoneyAccountBalance as jest.Mock).mockReturnValue({
totalFiatFormatted: 'CA$1,500.00',
});
const { getByText } = renderWithProvider(<MoneyAddMoneySheet />);

expect(getByText('Move your CA$1,500.00 mUSD')).toBeOnTheScreen();
});

it('falls back to the no-amount copy when the mUSD balance is unavailable', () => {
(useMusdBalance as jest.Mock).mockReturnValue({
fiatBalanceAggregatedFormatted: undefined,
(useMoneyAccountBalance as jest.Mock).mockReturnValue({
totalFiatFormatted: undefined,
});
const { getByText } = renderWithProvider(<MoneyAddMoneySheet />);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
import Tag from '../../../../../component-library/components/Tags/Tag';
import { strings } from '../../../../../../locales/i18n';
import { useStyles } from '../../../../../component-library/hooks';
import { useMusdBalance } from '../../../Earn/hooks/useMusdBalance';
import { useMusdConversionFlowData } from '../../../Earn/hooks/useMusdConversionFlowData';
import useMoneyAccountBalance from '../../hooks/useMoneyAccountBalance';
import {
MUSD_CONVERSION_DEFAULT_CHAIN_ID,
MUSD_TOKEN_ASSET_ID_BY_CHAIN,
Expand All @@ -40,7 +40,7 @@ const MoneyAddMoneySheet: React.FC = () => {
const navigation = useNavigation();
const { styles } = useStyles(styleSheet, {});

const { fiatBalanceAggregatedFormatted } = useMusdBalance();
const { totalFiatFormatted } = useMoneyAccountBalance();
const { getChainIdForBuyFlow } = useMusdConversionFlowData();
const { goToBuy } = useRampNavigation();
const { initiateDeposit } = useMoneyAccountDeposit();
Expand Down Expand Up @@ -94,9 +94,9 @@ const MoneyAddMoneySheet: React.FC = () => {
testID: MoneyAddMoneySheetTestIds.DEPOSIT_FUNDS_OPTION,
},
{
label: fiatBalanceAggregatedFormatted
label: totalFiatFormatted
? strings('money.add_money_sheet.move_musd', {
amount: fiatBalanceAggregatedFormatted,
amount: totalFiatFormatted,
})
: strings('money.add_money_sheet.move_musd_no_amount'),
icon: IconName.Add,
Expand Down
2 changes: 2 additions & 0 deletions app/components/UI/Rewards/RewardsNavigator.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ jest.mock('./hooks/useRewardsToast', () => ({
loading: jest.fn(),
entriesClosed: jest.fn(),
enableNotificationsNudge: jest.fn(),
outcomeWinner: jest.fn(),
outcomeNonWinner: jest.fn(),
},
})),
}));
Expand Down
7 changes: 6 additions & 1 deletion app/components/UI/Rewards/RewardsNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import { useReferralDetails } from './hooks/useReferralDetails';
import { useRewardsNotificationsNudge } from './hooks/useRewardsNotificationsNudge';
import useRewardsToast from './hooks/useRewardsToast';
import { strings } from '../../../../locales/i18n';
import PerpsTradingCampaignWinningView from './Views/PerpsTradingCampaignWinningView';

let sessionNotificationsNudgeShown = false;

const Stack = createStackNavigator();

const RewardsNavigator: React.FC = () => {
Expand Down Expand Up @@ -296,6 +296,11 @@ const RewardsNavigator: React.FC = () => {
component={PerpsTradingCampaignStatsView}
options={{ headerShown: false }}
/>
<Stack.Screen
name={Routes.REWARDS_PERPS_TRADING_CAMPAIGN_WINNING_VIEW}
component={PerpsTradingCampaignWinningView}
options={{ headerShown: false }}
/>
</>
) : null}
</Stack.Navigator>
Expand Down
Loading
Loading