Skip to content

Commit 9945468

Browse files
committed
fix: design feedback and unit test
1 parent e0def82 commit 9945468

File tree

2 files changed

+89
-3
lines changed

2 files changed

+89
-3
lines changed

app/components/UI/SecurityTrust/Views/SecurityTrustScreen.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,9 @@ const SecurityTrustScreen: React.FC = () => {
259259
>
260260
<Box twClassName="w-3 h-3 rounded-full bg-[#6B7FFF]" />
261261
<Text
262-
variant={TextVariant.BodySm}
262+
variant={TextVariant.BodyMd}
263263
color={TextColor.TextAlternative}
264+
fontWeight={FontWeight.Medium}
264265
>
265266
{strings('security_trust.top_10_holders')}
266267
</Text>
@@ -293,8 +294,9 @@ const SecurityTrustScreen: React.FC = () => {
293294
>
294295
<Box twClassName="w-3 h-3 rounded-full bg-[rgba(133,139,154,0.5)]" />
295296
<Text
296-
variant={TextVariant.BodySm}
297+
variant={TextVariant.BodyMd}
297298
color={TextColor.TextAlternative}
299+
fontWeight={FontWeight.Medium}
298300
>
299301
{strings('security_trust.other')}
300302
</Text>
@@ -457,7 +459,7 @@ const SecurityTrustScreen: React.FC = () => {
457459
<Box
458460
flexDirection={BoxFlexDirection.Row}
459461
alignItems={BoxAlignItems.Start}
460-
gap={4}
462+
gap={2}
461463
twClassName="w-full flex-wrap"
462464
>
463465
{metadata.externalLinks.homepage && (
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react-native';
3+
import SecurityBadgeBottomSheet from './SecurityBadgeBottomSheet';
4+
import { IconName, IconColor } from '@metamask/design-system-react-native';
5+
import { strings } from '../../../../../locales/i18n';
6+
import { MetaMetricsEvents } from '../../../../core/Analytics';
7+
8+
const mockTrackEvent = jest.fn();
9+
const mockCreateEventBuilder = jest.fn(() => ({
10+
addProperties: jest.fn().mockReturnThis(),
11+
build: jest.fn().mockReturnValue({}),
12+
}));
13+
14+
jest.mock('../../../hooks/useAnalytics/useAnalytics', () => ({
15+
useAnalytics: () => ({
16+
trackEvent: mockTrackEvent,
17+
createEventBuilder: mockCreateEventBuilder,
18+
}),
19+
}));
20+
21+
jest.mock('react-native-safe-area-context', () => ({
22+
useSafeAreaInsets: () => ({ top: 0, bottom: 0, left: 0, right: 0 }),
23+
useSafeAreaFrame: () => ({ x: 0, y: 0, width: 390, height: 844 }),
24+
SafeAreaProvider: ({ children }: { children: React.ReactNode }) => children,
25+
}));
26+
27+
const mockRouteParams = {
28+
icon: IconName.SecurityTick,
29+
iconColor: IconColor.SuccessDefault,
30+
title: 'Test Title',
31+
description: 'Test Description',
32+
source: 'badge',
33+
severity: 'Verified',
34+
tokenAddress: '0x1234567890abcdef',
35+
tokenSymbol: 'TEST',
36+
chainId: '0x1',
37+
};
38+
39+
jest.mock('@react-navigation/native', () => ({
40+
...jest.requireActual('@react-navigation/native'),
41+
useRoute: () => ({
42+
params: mockRouteParams,
43+
}),
44+
useNavigation: () => ({
45+
navigate: jest.fn(),
46+
goBack: jest.fn(),
47+
}),
48+
}));
49+
50+
describe('SecurityBadgeBottomSheet', () => {
51+
beforeEach(() => {
52+
jest.clearAllMocks();
53+
});
54+
55+
it('renders without crashing', () => {
56+
const { getByText } = render(<SecurityBadgeBottomSheet />);
57+
expect(getByText('Test Title')).toBeTruthy();
58+
expect(getByText('Test Description')).toBeTruthy();
59+
});
60+
61+
it('tracks bottom sheet opened event on mount', () => {
62+
render(<SecurityBadgeBottomSheet />);
63+
64+
expect(mockCreateEventBuilder).toHaveBeenCalledWith(
65+
MetaMetricsEvents.SECURITY_TRUST_BOTTOM_SHEET_OPENED,
66+
);
67+
expect(mockTrackEvent).toHaveBeenCalled();
68+
});
69+
70+
it('displays "Got it" button when onProceed is not provided', () => {
71+
const { getByText, queryByText } = render(<SecurityBadgeBottomSheet />);
72+
73+
expect(getByText(strings('security_trust.got_it'))).toBeTruthy();
74+
expect(queryByText(strings('security_trust.proceed'))).toBeNull();
75+
expect(queryByText(strings('security_trust.cancel'))).toBeNull();
76+
});
77+
78+
it('displays title and description from route params', () => {
79+
const { getByText } = render(<SecurityBadgeBottomSheet />);
80+
81+
expect(getByText('Test Title')).toBeTruthy();
82+
expect(getByText('Test Description')).toBeTruthy();
83+
});
84+
});

0 commit comments

Comments
 (0)