11import React from 'react' ;
22import { fireEvent , render } from '@testing-library/react-native' ;
3- import BigNumber from 'bignumber.js' ;
43import { BalanceProjection } from './BalanceProjection' ;
54import useMoneyAccountBalance from '../../hooks/useMoneyAccountBalance' ;
6- import useFiatFormatter from '../../../SimulationDetails/FiatDisplay/useFiatFormatter' ;
75import { strings } from '../../../../../../locales/i18n' ;
86import {
97 MONEY_TOOLTIP_NAMES ,
@@ -12,7 +10,6 @@ import {
1210import Routes from '../../../../../constants/navigation/Routes' ;
1311
1412jest . mock ( '../../hooks/useMoneyAccountBalance' ) ;
15- jest . mock ( '../../../SimulationDetails/FiatDisplay/useFiatFormatter' ) ;
1613
1714const mockTrackTooltipClicked = jest . fn ( ) ;
1815
@@ -35,7 +32,6 @@ jest.mock('@react-navigation/native', () => {
3532} ) ;
3633
3734const useMoneyAccountBalanceMock = jest . mocked ( useMoneyAccountBalance ) ;
38- const useFiatFormatterMock = jest . mocked ( useFiatFormatter ) ;
3935
4036const ONE_YEAR_LABEL = strings ( 'confirm.custom_amount.projected_balance' , {
4137 projectedYears : 1 ,
@@ -58,13 +54,8 @@ function mockBalance({
5854}
5955
6056describe ( 'BalanceProjection' , ( ) => {
61- const formatFiat = jest . fn (
62- ( value : BigNumber ) => `$${ value . toFixed ( 2 , BigNumber . ROUND_HALF_UP ) } ` ,
63- ) ;
64-
6557 beforeEach ( ( ) => {
6658 jest . clearAllMocks ( ) ;
67- useFiatFormatterMock . mockReturnValue ( formatFiat ) ;
6859 } ) ;
6960
7061 it ( 'renders label and projected balance for $1,000 at apyDecimal 0.04 over 1 year (~$1,040.00)' , ( ) => {
@@ -76,7 +67,7 @@ describe('BalanceProjection', () => {
7667
7768 expect ( getByTestId ( 'balance-projection' ) ) . toBeOnTheScreen ( ) ;
7869 expect ( getByText ( ONE_YEAR_LABEL , { exact : false } ) ) . toBeOnTheScreen ( ) ;
79- expect ( getByText ( '$1040 .00' ) ) . toBeOnTheScreen ( ) ;
70+ expect ( getByText ( '$1,040 .00' ) ) . toBeOnTheScreen ( ) ;
8071 } ) ;
8172
8273 it ( 'compounds the projection over multiple years' , ( ) => {
@@ -86,7 +77,7 @@ describe('BalanceProjection', () => {
8677 < BalanceProjection amountFiat = "1000" projectedYears = { 5 } /> ,
8778 ) ;
8879
89- expect ( getByText ( '$1216 .65' ) ) . toBeOnTheScreen ( ) ;
80+ expect ( getByText ( '$1,216 .65' ) ) . toBeOnTheScreen ( ) ;
9081 } ) ;
9182
9283 it ( 'renders the APY pitch when amountFiat is "0"' , ( ) => {
@@ -303,14 +294,14 @@ describe('BalanceProjection', () => {
303294 expect ( queryByTestId ( 'balance-projection-apy-pitch' ) ) . toBeNull ( ) ;
304295 } ) ;
305296
306- it ( 'passes a BigNumber to the fiat formatter when projecting ' , ( ) => {
307- mockBalance ( { apyDecimal : 0.04 , apyPercent : 4 } ) ;
297+ it ( 'renders the projected balance in dollars regardless of the preferred currency ' , ( ) => {
298+ mockBalance ( { apyDecimal : 0.05 , apyPercent : 5 } ) ;
308299
309- render ( < BalanceProjection amountFiat = "1000" projectedYears = { 1 } /> ) ;
300+ const { getByText, queryByText } = render (
301+ < BalanceProjection amountFiat = "100" projectedYears = { 1 } /> ,
302+ ) ;
310303
311- expect ( formatFiat ) . toHaveBeenCalledTimes ( 1 ) ;
312- const passed = formatFiat . mock . calls [ 0 ] [ 0 ] ;
313- expect ( BigNumber . isBigNumber ( passed ) ) . toBe ( true ) ;
314- expect ( passed . toFixed ( 2 ) ) . toBe ( '1040.00' ) ;
304+ expect ( getByText ( '$105.00' ) ) . toBeOnTheScreen ( ) ;
305+ expect ( queryByText ( / € / ) ) . toBeNull ( ) ;
315306 } ) ;
316307} ) ;
0 commit comments