@@ -17,11 +17,20 @@ const styles = StyleSheet.create({
17
17
description : {
18
18
color : red500 ,
19
19
} ,
20
+ content : {
21
+ paddingLeft : 0 ,
22
+ } ,
20
23
} ) ;
21
24
25
+ const testID = 'list-item' ;
26
+
22
27
it ( 'renders list item with title and description' , ( ) => {
23
28
const tree = render (
24
- < ListItem title = "First Item" description = "Description for first item" />
29
+ < ListItem
30
+ title = "First Item"
31
+ testID = { testID }
32
+ description = "Description for first item"
33
+ />
25
34
) . toJSON ( ) ;
26
35
27
36
expect ( tree ) . toMatchSnapshot ( ) ;
@@ -31,6 +40,7 @@ it('renders list item with left item', () => {
31
40
const tree = render (
32
41
< ListItem
33
42
title = "First Item"
43
+ testID = { testID }
34
44
left = { ( props ) => < ListIcon { ...props } icon = "folder" /> }
35
45
/>
36
46
) . toJSON ( ) ;
@@ -40,7 +50,11 @@ it('renders list item with left item', () => {
40
50
41
51
it ( 'renders list item with right item' , ( ) => {
42
52
const tree = render (
43
- < ListItem title = "First Item" right = { ( ) => < Text > GG</ Text > } />
53
+ < ListItem
54
+ title = "First Item"
55
+ testID = { testID }
56
+ right = { ( ) => < Text > GG</ Text > }
57
+ />
44
58
) . toJSON ( ) ;
45
59
46
60
expect ( tree ) . toMatchSnapshot ( ) ;
@@ -51,6 +65,7 @@ it('renders list item with left and right items', () => {
51
65
< ListItem
52
66
title = "First Item"
53
67
description = "Item description"
68
+ testID = { testID }
54
69
left = { ( ) => < Text > GG</ Text > }
55
70
right = { ( props ) => < ListIcon { ...props } icon = "folder" /> }
56
71
/>
@@ -64,6 +79,7 @@ it('renders list item with custom title and description styles', () => {
64
79
< ListItem
65
80
title = "First Item"
66
81
description = "Item description"
82
+ testID = { testID }
67
83
titleStyle = { styles . title }
68
84
descriptionStyle = { styles . description }
69
85
/>
@@ -93,6 +109,7 @@ it('renders list item with custom description', () => {
93
109
</ View >
94
110
</ View >
95
111
) }
112
+ testID = { testID }
96
113
/>
97
114
) . toJSON ( ) ;
98
115
@@ -106,6 +123,7 @@ it('renders with a description with typeof number', () => {
106
123
description = { 123 }
107
124
titleStyle = { styles . title }
108
125
descriptionStyle = { styles . description }
126
+ testID = { testID }
109
127
/>
110
128
) . toJSON ( ) ;
111
129
@@ -120,10 +138,24 @@ it('calling onPress on ListItem right component', () => {
120
138
< ListItem
121
139
title = "First Item"
122
140
description = "Item description"
141
+ testID = { testID }
123
142
right = { ( ) => < IconButton icon = "pencil" onPress = { onPress } /> }
124
143
/>
125
144
) ;
126
145
127
146
fireEvent ( getByTestId ( 'icon-button' ) , 'onPress' ) ;
128
147
expect ( onPress ) . toHaveBeenCalledTimes ( 1 ) ;
129
148
} ) ;
149
+
150
+ it ( 'renders list item with custom content style' , ( ) => {
151
+ const { getByTestId } = render (
152
+ < ListItem
153
+ title = "First Item"
154
+ description = "Item description"
155
+ contentStyle = { styles . content }
156
+ testID = { testID }
157
+ />
158
+ ) ;
159
+
160
+ expect ( getByTestId ( 'list-item-content' ) ) . toHaveStyle ( styles . content ) ;
161
+ } ) ;
0 commit comments