@@ -5,63 +5,92 @@ import '../extend-expect';
5
5
6
6
test ( '.toBeSelected() basic case' , ( ) => {
7
7
render (
8
- < View >
8
+ < >
9
9
< View testID = "selected" accessibilityState = { { selected : true } } />
10
+ < View testID = "selected-aria" aria-selected />
10
11
< View testID = "not-selected" accessibilityState = { { selected : false } } />
11
- < View testID = "no-accessibilityState" />
12
- </ View >
12
+ < View testID = "not-selected-aria" aria-selected = { false } />
13
+ < View testID = "default" />
14
+ </ >
13
15
) ;
14
16
15
17
expect ( screen . getByTestId ( 'selected' ) ) . toBeSelected ( ) ;
18
+ expect ( screen . getByTestId ( 'selected-aria' ) ) . toBeSelected ( ) ;
16
19
expect ( screen . getByTestId ( 'not-selected' ) ) . not . toBeSelected ( ) ;
17
- expect ( screen . getByTestId ( 'no-accessibilityState' ) ) . not . toBeSelected ( ) ;
20
+ expect ( screen . getByTestId ( 'not-selected-aria' ) ) . not . toBeSelected ( ) ;
21
+ expect ( screen . getByTestId ( 'default' ) ) . not . toBeSelected ( ) ;
18
22
} ) ;
19
23
20
24
test ( '.toBeSelected() error messages' , ( ) => {
21
25
render (
22
- < View >
26
+ < >
23
27
< View testID = "selected" accessibilityState = { { selected : true } } />
28
+ < View testID = "selected-aria" aria-selected />
24
29
< View testID = "not-selected" accessibilityState = { { selected : false } } />
25
- < View testID = "no-accessibilityState" />
26
- </ View >
30
+ < View testID = "not-selected-aria" aria-selected = { false } />
31
+ < View testID = "default" />
32
+ </ >
27
33
) ;
28
34
29
- expect ( ( ) => expect ( screen . getByTestId ( 'not- selected' ) ) . toBeSelected ( ) )
35
+ expect ( ( ) => expect ( screen . getByTestId ( 'selected' ) ) . not . toBeSelected ( ) )
30
36
. toThrowErrorMatchingInlineSnapshot ( `
31
- "expect(element).toBeSelected()
37
+ "expect(element).not. toBeSelected()
32
38
33
- Received element is not selected
39
+ Received element is selected
34
40
<View
35
41
accessibilityState={
36
42
{
37
- "selected": false ,
43
+ "selected": true ,
38
44
}
39
45
}
40
- testID="not- selected"
46
+ testID="selected"
41
47
/>"
42
48
` ) ;
43
- expect ( ( ) => expect ( screen . getByTestId ( 'selected' ) ) . not . toBeSelected ( ) )
49
+
50
+ expect ( ( ) => expect ( screen . getByTestId ( 'selected-aria' ) ) . not . toBeSelected ( ) )
44
51
. toThrowErrorMatchingInlineSnapshot ( `
45
52
"expect(element).not.toBeSelected()
46
53
47
54
Received element is selected
55
+ <View
56
+ aria-selected={true}
57
+ testID="selected-aria"
58
+ />"
59
+ ` ) ;
60
+
61
+ expect ( ( ) => expect ( screen . getByTestId ( 'not-selected' ) ) . toBeSelected ( ) )
62
+ . toThrowErrorMatchingInlineSnapshot ( `
63
+ "expect(element).toBeSelected()
64
+
65
+ Received element is not selected
48
66
<View
49
67
accessibilityState={
50
68
{
51
- "selected": true ,
69
+ "selected": false ,
52
70
}
53
71
}
54
- testID="selected"
72
+ testID="not- selected"
55
73
/>"
56
74
` ) ;
57
- expect ( ( ) =>
58
- expect ( screen . getByTestId ( 'no-accessibilityState' ) ) . toBeSelected ( )
59
- ) . toThrowErrorMatchingInlineSnapshot ( `
75
+
76
+ expect ( ( ) => expect ( screen . getByTestId ( 'not-selected-aria' ) ) . toBeSelected ( ) )
77
+ . toThrowErrorMatchingInlineSnapshot ( `
78
+ "expect(element).toBeSelected()
79
+
80
+ Received element is not selected
81
+ <View
82
+ aria-selected={false}
83
+ testID="not-selected-aria"
84
+ />"
85
+ ` ) ;
86
+
87
+ expect ( ( ) => expect ( screen . getByTestId ( 'default' ) ) . toBeSelected ( ) )
88
+ . toThrowErrorMatchingInlineSnapshot ( `
60
89
"expect(element).toBeSelected()
61
90
62
91
Received element is not selected
63
92
<View
64
- testID="no-accessibilityState "
93
+ testID="default "
65
94
/>"
66
95
` ) ;
67
96
} ) ;
0 commit comments