@@ -20,6 +20,7 @@ import {
2020} from './useMoneyAccount' ;
2121import { shouldShowMoneyFirstTimeDepositAnimation } from '../utils/firstTimeDeposit' ;
2222import { getMemoizedInternalAccountByAddress } from '../../../../selectors/accountsController' ;
23+ import { selectCurrentCurrency } from '../../../../selectors/currencyRateController' ;
2324import { selectAccountToGroupMap } from '../../../../selectors/multichainAccounts/accountTreeController' ;
2425import Routes from '../../../../constants/navigation/Routes' ;
2526import NavigationService from '../../../../core/NavigationService/NavigationService' ;
@@ -683,7 +684,7 @@ describe('useMoneyTransactionStatus', () => {
683684 } ) ;
684685 } ) ;
685686
686- it ( 'confirmed → success toast with decoded fiat amount' , ( ) => {
687+ it ( 'confirmed → success toast with decoded dollar amount' , ( ) => {
687688 const { confirmedHandler } = renderAndGetHandlers ( ) ;
688689
689690 confirmedHandler (
@@ -699,8 +700,7 @@ describe('useMoneyTransactionStatus', () => {
699700
700701 expect ( depositSuccessFn ) . toHaveBeenCalledTimes ( 1 ) ;
701702 const params = depositSuccessFn . mock . calls [ 0 ] [ 0 ] ;
702- expect ( params . amountFiat ) . toContain ( 'mUSD' ) ;
703- expect ( params . amountFiat ) . toContain ( '12.34' ) ;
703+ expect ( params . amountFiat ) . toBe ( '$12.34' ) ;
704704 } ) ;
705705
706706 it ( 'failed → deposit failed toast' , ( ) => {
@@ -1508,37 +1508,82 @@ describe('useMoneyTransactionStatus', () => {
15081508 } ) ;
15091509
15101510 describe ( 'formatMusdAmountForToast' , ( ) => {
1511- it ( 'falls back to mUSD format when no fiat rate is available' , ( ) => {
1512- expect ( formatMusdAmountForToast ( BigInt ( 1_000_000 ) ) ) . toBe ( '1.00 mUSD' ) ;
1513- expect ( formatMusdAmountForToast ( BigInt ( 123_456 ) ) ) . toBe ( '0.12 mUSD' ) ;
1511+ it ( 'formats the decoded mUSD amount as US dollars' , ( ) => {
1512+ expect ( formatMusdAmountForToast ( BigInt ( 1_000_000 ) ) ) . toBe ( '$1.00' ) ;
1513+ expect ( formatMusdAmountForToast ( BigInt ( 123_456 ) ) ) . toBe ( '$0.12' ) ;
1514+ expect ( formatMusdAmountForToast ( BigInt ( 5_000_000 ) ) ) . toBe ( '$5.00' ) ;
15141515 } ) ;
1516+ } ) ;
1517+
1518+ describe ( 'USD formatting regardless of preferred currency' , ( ) => {
1519+ beforeEach ( ( ) => {
1520+ jest . mocked ( selectCurrentCurrency ) . mockReturnValue ( 'EUR' ) ;
1521+ } ) ;
1522+
1523+ afterEach ( ( ) => {
1524+ jest . mocked ( selectCurrentCurrency ) . mockReturnValue ( 'usd' ) ;
1525+ } ) ;
1526+
1527+ it ( 'confirmed deposit → success amount is dollar-formatted when the preferred currency is EUR' , ( ) => {
1528+ const { confirmedHandler } = renderAndGetHandlers ( ) ;
15151529
1516- it ( 'formats as fiat when token market data, currency rates and network config resolve' , ( ) => {
1517- const tokenRatesMock = jest . requireMock (
1518- '../../../../selectors/tokenRatesController' ,
1530+ confirmedHandler (
1531+ buildTxMeta ( {
1532+ type : TransactionType . moneyAccountDeposit ,
1533+ status : TransactionStatus . confirmed ,
1534+ txParams : {
1535+ from : '0x0' ,
1536+ data : encodeDepositData ( BigInt ( 12_340_000 ) ) ,
1537+ } ,
1538+ } ) ,
15191539 ) ;
1520- const currencyRatesMock = jest . requireMock (
1521- '../../../../selectors/currencyRateController' ,
1540+
1541+ expect ( depositSuccessFn ) . toHaveBeenCalledTimes ( 1 ) ;
1542+ const amountFiat = depositSuccessFn . mock . calls [ 0 ] [ 0 ] . amountFiat ;
1543+ expect ( amountFiat ) . toMatch ( / ^ \$ / ) ;
1544+ expect ( amountFiat ) . not . toContain ( '€' ) ;
1545+ } ) ;
1546+
1547+ it ( 'confirmed withdraw → success amount is dollar-formatted when the preferred currency is EUR' , ( ) => {
1548+ const { confirmedHandler } = renderAndGetHandlers ( ) ;
1549+
1550+ confirmedHandler (
1551+ buildTxMeta ( {
1552+ type : TransactionType . moneyAccountWithdraw ,
1553+ status : TransactionStatus . confirmed ,
1554+ txParams : {
1555+ from : '0x0' ,
1556+ data : encodeWithdrawData ( BigInt ( 50_000_000 ) ) ,
1557+ } ,
1558+ } ) ,
15221559 ) ;
1523- const networkConfigMock = jest . requireMock (
1524- '../../../../selectors/networkController' ,
1560+
1561+ expect ( withdrawSuccessFn ) . toHaveBeenCalledTimes ( 1 ) ;
1562+ const amountFiat = withdrawSuccessFn . mock . calls [ 0 ] [ 0 ] . amountFiat ;
1563+ expect ( amountFiat ) . toMatch ( / ^ \$ / ) ;
1564+ expect ( amountFiat ) . not . toContain ( '€' ) ;
1565+ } ) ;
1566+
1567+ it ( 'confirmed perps send → success amount is dollar-formatted when the preferred currency is EUR' , ( ) => {
1568+ const { confirmedHandler } = renderAndGetHandlers ( ) ;
1569+
1570+ confirmedHandler (
1571+ buildTxMeta ( {
1572+ id : 'eur-send-tx' ,
1573+ type : TransactionType . perpsDeposit ,
1574+ status : TransactionStatus . confirmed ,
1575+ metamaskPay : {
1576+ tokenAddress : MUSD_ADDRESS ,
1577+ chainId : CHAIN_IDS . MONAD ,
1578+ targetFiat : '100' ,
1579+ } ,
1580+ } as unknown as Partial < TransactionMeta > ) ,
15251581 ) ;
1526- tokenRatesMock . selectTokenMarketData . mockReturnValueOnce ( {
1527- '0x1' : {
1528- '0xacA92E438df0B2401fF60dA7E4337B687a2435DA' : { price : 1 } ,
1529- } ,
1530- } ) ;
1531- currencyRatesMock . selectCurrencyRates . mockReturnValueOnce ( {
1532- ETH : { conversionRate : 2 } ,
1533- } ) ;
1534- networkConfigMock . selectNetworkConfigurations . mockReturnValueOnce ( {
1535- '0x1' : { nativeCurrency : 'ETH' } ,
1536- } ) ;
1537- currencyRatesMock . selectCurrentCurrency . mockReturnValueOnce ( 'usd' ) ;
15381582
1539- const formatted = formatMusdAmountForToast ( BigInt ( 5_000_000 ) ) ;
1540- expect ( formatted ) . not . toContain ( 'mUSD' ) ;
1541- expect ( formatted ) . toMatch ( / 1 0 / ) ;
1583+ expect ( sendSuccessFn ) . toHaveBeenCalledTimes ( 1 ) ;
1584+ const amountFiat = sendSuccessFn . mock . calls [ 0 ] [ 0 ] . amountFiat ;
1585+ expect ( amountFiat ) . toMatch ( / ^ \$ / ) ;
1586+ expect ( amountFiat ) . not . toContain ( '€' ) ;
15421587 } ) ;
15431588 } ) ;
15441589
0 commit comments