-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathPerpsMoreSection.test.tsx
More file actions
66 lines (55 loc) · 2.02 KB
/
Copy pathPerpsMoreSection.test.tsx
File metadata and controls
66 lines (55 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react-native';
import { IconName } from '@metamask/design-system-react-native';
import PerpsMoreSection, { type PerpsMoreItem } from './PerpsMoreSection';
import { PerpsMoreSectionTestIds } from './PerpsMoreSection.testIds';
describe('PerpsMoreSection', () => {
const mockOnPressSupport = jest.fn();
const mockOnPressLearn = jest.fn();
const items: PerpsMoreItem[] = [
{
label: 'Contact support',
startIconName: IconName.Sms,
onPress: mockOnPressSupport,
testID: 'perps-more-support-button',
},
{
label: 'Learn the basics of perps',
startIconName: IconName.Book,
onPress: mockOnPressLearn,
testID: 'perps-more-learn-button',
},
];
beforeEach(() => {
jest.clearAllMocks();
});
it('renders the More section title and items', () => {
render(<PerpsMoreSection items={items} />);
expect(screen.getByText('More')).toBeOnTheScreen();
expect(screen.getByText('Contact support')).toBeOnTheScreen();
expect(screen.getByText('Learn the basics of perps')).toBeOnTheScreen();
expect(
screen.getByTestId(PerpsMoreSectionTestIds.SECTION),
).toBeOnTheScreen();
});
it('calls onPress when an item is pressed', () => {
render(<PerpsMoreSection items={items} />);
fireEvent.press(screen.getByTestId('perps-more-support-button'));
fireEvent.press(screen.getByTestId('perps-more-learn-button'));
expect(mockOnPressSupport).toHaveBeenCalledTimes(1);
expect(mockOnPressLearn).toHaveBeenCalledTimes(1);
});
it('renders end icon when provided', () => {
const itemsWithEndIcon: PerpsMoreItem[] = [
{
label: 'Contact support',
startIconName: IconName.Sms,
endIconName: IconName.Export,
onPress: mockOnPressSupport,
testID: 'perps-more-support-button',
},
];
render(<PerpsMoreSection items={itemsWithEndIcon} />);
expect(screen.getByText('Contact support')).toBeOnTheScreen();
});
});