Skip to content

Commit 62f8e82

Browse files
committed
fix: label main and secondary balances
1 parent 85c526b commit 62f8e82

File tree

12 files changed

+102
-105
lines changed

12 files changed

+102
-105
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export const FIAT_BALANCE_TEST_ID = 'fiat-balance-test-id';
2-
export const MAIN_BALANCE_TEST_ID = 'main-balance-test-id';
1+
export const BALANCE_TEST_ID = 'balance-test-id';
2+
export const SECONDARY_BALANCE_TEST_ID = 'secondary-balance-test-id';

app/components/UI/AssetElement/index.test.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { shallow } from 'enzyme';
33
import { render, fireEvent } from '@testing-library/react-native';
44
import AssetElement from './';
55
import { getAssetTestId } from '../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds';
6-
import { FIAT_BALANCE_TEST_ID, MAIN_BALANCE_TEST_ID } from './index.constants';
6+
import { BALANCE_TEST_ID, SECONDARY_BALANCE_TEST_ID } from './index.constants';
77

88
describe('AssetElement', () => {
99
const onPressMock = jest.fn();
@@ -28,7 +28,7 @@ describe('AssetElement', () => {
2828
expect(wrapper).toMatchSnapshot();
2929
});
3030

31-
it('renders the asset balance if provided', () => {
31+
it('renders the main balance if provided', () => {
3232
const { getByText } = render(
3333
<AssetElement asset={erc20Token} balance={erc20Token.balance} />,
3434
);
@@ -56,33 +56,33 @@ describe('AssetElement', () => {
5656
expect(onLongPressMock).toHaveBeenCalledWith(erc20Token);
5757
});
5858

59-
it('renders the fiat and token balance', () => {
59+
it('renders the main and secondary balance', () => {
6060
const { getByTestId } = render(
6161
<AssetElement
6262
balance={erc20Token.balance}
63-
mainBalance={erc20Token.balance}
63+
secondaryBalance={erc20Token.balance}
6464
asset={erc20Token}
6565
/>,
6666
);
6767

68-
expect(getByTestId(FIAT_BALANCE_TEST_ID)).toBeDefined();
69-
expect(getByTestId(MAIN_BALANCE_TEST_ID)).toBeDefined();
68+
expect(getByTestId(BALANCE_TEST_ID)).toBeDefined();
69+
expect(getByTestId(SECONDARY_BALANCE_TEST_ID)).toBeDefined();
7070
});
7171

72-
it('renders the fiat balance with privacy mode', () => {
72+
it('renders the main and secondary balance with privacy mode', () => {
7373
const { getByTestId } = render(
7474
<AssetElement
7575
asset={erc20Token}
7676
balance={erc20Token.balance}
77-
mainBalance={erc20Token.balance}
77+
secondaryBalance={erc20Token.balance}
7878
privacyMode
7979
/>,
8080
);
8181

82-
const fiatBalance = getByTestId(FIAT_BALANCE_TEST_ID);
83-
const mainBalance = getByTestId(MAIN_BALANCE_TEST_ID);
82+
const mainBalance = getByTestId(BALANCE_TEST_ID);
83+
const secondaryBalance = getByTestId(SECONDARY_BALANCE_TEST_ID);
8484

85-
expect(fiatBalance.props.children).toBe('•••••••••');
86-
expect(mainBalance.props.children).toBe('••••••');
85+
expect(mainBalance.props.children).toBe('•••••••••');
86+
expect(secondaryBalance.props.children).toBe('••••••');
8787
});
8888
});

app/components/UI/AssetElement/index.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ import { useTheme } from '../../../util/theme';
1616
import SensitiveText, {
1717
SensitiveTextLength,
1818
} from '../../../component-library/components/Texts/SensitiveText';
19-
import { FIAT_BALANCE_TEST_ID, MAIN_BALANCE_TEST_ID } from './index.constants';
19+
import { BALANCE_TEST_ID, SECONDARY_BALANCE_TEST_ID } from './index.constants';
2020

2121
interface AssetElementProps {
2222
children?: React.ReactNode;
2323
asset: TokenI;
2424
onPress?: (asset: TokenI) => void;
2525
onLongPress?: ((asset: TokenI) => void) | null;
2626
balance?: string;
27-
mainBalance?: string | null;
27+
secondaryBalance?: string;
2828
privacyMode?: boolean;
2929
}
3030

@@ -48,7 +48,7 @@ const createStyles = (colors: Colors) =>
4848
skeleton: {
4949
width: 50,
5050
},
51-
balanceFiat: {
51+
secondaryBalance: {
5252
color: colors.text.alternative,
5353
paddingHorizontal: 0,
5454
...fontStyles.normal,
@@ -62,8 +62,8 @@ const createStyles = (colors: Colors) =>
6262
const AssetElement: React.FC<AssetElementProps> = ({
6363
children,
6464
balance,
65+
secondaryBalance,
6566
asset,
66-
mainBalance = null,
6767
onPress,
6868
onLongPress,
6969
privacyMode = false,
@@ -101,7 +101,7 @@ const AssetElement: React.FC<AssetElementProps> = ({
101101
}
102102
isHidden={privacyMode}
103103
length={SensitiveTextLength.Medium}
104-
testID={FIAT_BALANCE_TEST_ID}
104+
testID={BALANCE_TEST_ID}
105105
>
106106
{balance === TOKEN_BALANCE_LOADING ? (
107107
<SkeletonText thin style={styles.skeleton} />
@@ -110,18 +110,18 @@ const AssetElement: React.FC<AssetElementProps> = ({
110110
)}
111111
</SensitiveText>
112112
)}
113-
{mainBalance ? (
113+
{secondaryBalance ? (
114114
<SensitiveText
115115
variant={TextVariant.BodyMD}
116-
style={styles.balanceFiat}
116+
style={styles.secondaryBalance}
117117
isHidden={privacyMode}
118118
length={SensitiveTextLength.Short}
119-
testID={MAIN_BALANCE_TEST_ID}
119+
testID={SECONDARY_BALANCE_TEST_ID}
120120
>
121-
{mainBalance === TOKEN_BALANCE_LOADING ? (
121+
{secondaryBalance === TOKEN_BALANCE_LOADING ? (
122122
<SkeletonText thin style={styles.skeleton} />
123123
) : (
124-
mainBalance
124+
secondaryBalance
125125
)}
126126
</SensitiveText>
127127
) : null}

app/components/UI/AssetOverview/Balance/Balance.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ const Balance = ({ asset, mainBalance, secondaryBalance }: BalanceProps) => {
144144
</Text>
145145
<AssetElement
146146
asset={asset}
147-
mainBalance={mainBalance}
148-
balance={secondaryBalance}
147+
balance={mainBalance}
148+
secondaryBalance={secondaryBalance}
149149
onPress={() =>
150150
!asset.isETH &&
151151
!asset.isNative &&

app/components/UI/AssetOverview/Balance/__snapshots__/index.test.tsx.snap

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Balance should render correctly with a fiat balance 1`] = `
3+
exports[`Balance should render correctly with main and secondary balance 1`] = `
44
<View
55
style={
66
{
@@ -199,9 +199,9 @@ exports[`Balance should render correctly with a fiat balance 1`] = `
199199
"lineHeight": 24,
200200
}
201201
}
202-
testID="fiat-balance-test-id"
202+
testID="balance-test-id"
203203
>
204-
456
204+
123
205205
</Text>
206206
<Text
207207
accessibilityRole="text"
@@ -217,16 +217,16 @@ exports[`Balance should render correctly with a fiat balance 1`] = `
217217
"textTransform": "uppercase",
218218
}
219219
}
220-
testID="main-balance-test-id"
220+
testID="secondary-balance-test-id"
221221
>
222-
123
222+
456
223223
</Text>
224224
</View>
225225
</TouchableOpacity>
226226
</View>
227227
`;
228228

229-
exports[`Balance should render correctly without a fiat balance 1`] = `
229+
exports[`Balance should render correctly without a secondary balance 1`] = `
230230
<View
231231
style={
232232
{
@@ -417,17 +417,15 @@ exports[`Balance should render correctly without a fiat balance 1`] = `
417417
accessibilityRole="text"
418418
style={
419419
{
420-
"color": "#6a737d",
421-
"fontFamily": "EuclidCircularB-Regular",
422-
"fontSize": 14,
423-
"fontWeight": "400",
420+
"color": "#141618",
421+
"fontFamily": "EuclidCircularB-Medium",
422+
"fontSize": 16,
423+
"fontWeight": "500",
424424
"letterSpacing": 0,
425-
"lineHeight": 22,
426-
"paddingHorizontal": 0,
427-
"textTransform": "uppercase",
425+
"lineHeight": 24,
428426
}
429427
}
430-
testID="main-balance-test-id"
428+
testID="balance-test-id"
431429
>
432430
123
433431
</Text>

app/components/UI/AssetOverview/Balance/index.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ describe('Balance', () => {
152152
});
153153

154154
if (!isPortfolioViewEnabled()) {
155-
it('should render correctly with a fiat balance', () => {
155+
it('should render correctly with main and secondary balance', () => {
156156
const wrapper = render(
157157
<Balance asset={mockDAI} mainBalance="123" secondaryBalance="456" />,
158158
);
@@ -161,7 +161,7 @@ describe('Balance', () => {
161161
}
162162

163163
if (!isPortfolioViewEnabled()) {
164-
it('should render correctly without a fiat balance', () => {
164+
it('should render correctly without a secondary balance', () => {
165165
const wrapper = render(
166166
<Balance
167167
asset={mockDAI}

app/components/UI/AssetOverview/__snapshots__/AssetOverview.test.tsx.snap

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,17 +1102,15 @@ exports[`AssetOverview should render correctly 1`] = `
11021102
accessibilityRole="text"
11031103
style={
11041104
{
1105-
"color": "#6a737d",
1106-
"fontFamily": "EuclidCircularB-Regular",
1107-
"fontSize": 14,
1108-
"fontWeight": "400",
1105+
"color": "#141618",
1106+
"fontFamily": "EuclidCircularB-Medium",
1107+
"fontSize": 16,
1108+
"fontWeight": "500",
11091109
"letterSpacing": 0,
1110-
"lineHeight": 22,
1111-
"paddingHorizontal": 0,
1112-
"textTransform": "uppercase",
1110+
"lineHeight": 24,
11131111
}
11141112
}
1115-
testID="main-balance-test-id"
1113+
testID="balance-test-id"
11161114
>
11171115
0 ETH
11181116
</Text>
@@ -2241,9 +2239,9 @@ exports[`AssetOverview should render correctly when portfolio view is enabled 1`
22412239
"lineHeight": 24,
22422240
}
22432241
}
2244-
testID="fiat-balance-test-id"
2242+
testID="balance-test-id"
22452243
>
2246-
1500
2244+
0 ETH
22472245
</Text>
22482246
<Text
22492247
accessibilityRole="text"
@@ -2259,9 +2257,9 @@ exports[`AssetOverview should render correctly when portfolio view is enabled 1`
22592257
"textTransform": "uppercase",
22602258
}
22612259
}
2262-
testID="main-balance-test-id"
2260+
testID="secondary-balance-test-id"
22632261
>
2264-
0 ETH
2262+
1500
22652263
</Text>
22662264
</View>
22672265
</TouchableOpacity>

app/components/UI/NonEvmTokens/__snapshots__/index.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ exports[`NonEvmTokens should render correctly 1`] = `
554554
"lineHeight": 24,
555555
}
556556
}
557-
testID="fiat-balance-test-id"
557+
testID="balance-test-id"
558558
>
559559
5.5 SOL
560560
</Text>
@@ -572,7 +572,7 @@ exports[`NonEvmTokens should render correctly 1`] = `
572572
"textTransform": "uppercase",
573573
}
574574
}
575-
testID="main-balance-test-id"
575+
testID="secondary-balance-test-id"
576576
>
577577
<View
578578
style={

app/components/UI/NonEvmTokens/index.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const initialState = {
101101
},
102102
settings: {
103103
showTestNetworks: true,
104+
primaryCurrency: 'ETH',
104105
},
105106
};
106107

@@ -128,14 +129,14 @@ describe('NonEvmTokens', () => {
128129
it('should display the Solana token with correct balance', async () => {
129130
const { getByTestId, getByText } = renderComponent();
130131
expect(getByText('Solana')).toBeDefined();
131-
const balanceText = getByTestId('fiat-balance-test-id');
132+
const balanceText = getByTestId('balance-test-id');
132133
expect(balanceText.props.children).toBe('5.5 SOL');
133134
});
134135

135136
it('should show fiat value', async () => {
136137
const { getByTestId } = renderComponent();
137138
// With balance 5.5 and conversion rate 100, fiat value should be $550.00
138-
const balanceText = getByTestId('main-balance-test-id');
139+
const balanceText = getByTestId('secondary-balance-test-id');
139140
expect(balanceText).toBeDefined();
140141
});
141142

app/components/UI/Stake/components/StakingBalance/StakingBalance.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ const StakingBalanceContent = ({ asset }: StakingBalanceProps) => {
207207
{hasEthToUnstake && !isLoadingPooledStakesData && (
208208
<AssetElement
209209
asset={asset}
210-
mainBalance={stakedBalanceETH}
210+
secondaryBalance={stakedBalanceETH}
211211
balance={stakedBalanceFiat}
212212
>
213213
<BadgeWrapper

app/components/UI/Tokens/TokenList/TokenListItem/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ export const TokenListItem = React.memo(
324324
onPress={onItemPress}
325325
onLongPress={asset.isETH || asset.isNative ? null : showRemoveMenu}
326326
asset={asset}
327-
balance={secondaryBalance}
328-
mainBalance={mainBalance}
327+
balance={mainBalance}
328+
secondaryBalance={secondaryBalance}
329329
privacyMode={privacyMode}
330330
>
331331
{showNetworkBadge ? (

0 commit comments

Comments
 (0)