-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathListItemMultiSelectButton.test.tsx
More file actions
61 lines (56 loc) · 1.87 KB
/
ListItemMultiSelectButton.test.tsx
File metadata and controls
61 lines (56 loc) · 1.87 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
// Third party dependencies.
import React from 'react';
import { render, fireEvent } from '@testing-library/react-native';
import { View } from 'react-native';
// Internal dependencies.
import ListItemMultiSelectButton from './ListItemMultiSelectButton';
import { IconName } from '../../../component-library/components/Icons/Icon'; // Adjust the import path as necessary
import { BUTTON_TEST_ID } from './ListItemMultiSelectButton.constants';
describe('ListItemMultiSelectButton', () => {
it('should render correctly with default props', () => {
const wrapper = render(
<ListItemMultiSelectButton>
<View />
</ListItemMultiSelectButton>,
);
expect(wrapper).toMatchSnapshot();
});
it('should call onPress when the button is pressed', () => {
const mockOnPress = jest.fn();
const { getByRole } = render(
<ListItemMultiSelectButton
onPress={mockOnPress}
buttonProps={{
onButtonClick: mockOnPress,
}}
>
<View />
</ListItemMultiSelectButton>,
);
fireEvent.press(getByRole('button'));
expect(mockOnPress).toHaveBeenCalled();
});
it('should render the button icon with the correct name', () => {
const { getByTestId } = render(
<ListItemMultiSelectButton buttonIcon={IconName.Check}>
<View />
</ListItemMultiSelectButton>,
);
expect(getByTestId(BUTTON_TEST_ID)).not.toBeNull();
});
it('should call onButtonClick when the button icon is pressed', () => {
const mockOnButtonClick = jest.fn();
const { getByTestId } = render(
<ListItemMultiSelectButton
buttonIcon={IconName.Check}
buttonProps={{
onButtonClick: mockOnButtonClick,
}}
>
<View />
</ListItemMultiSelectButton>,
);
fireEvent.press(getByTestId(BUTTON_TEST_ID));
expect(mockOnButtonClick).toHaveBeenCalled();
});
});