1- import { Platform } from "react-native" ;
2-
31import { fireEvent , screen } from "@testing-library/react-native" ;
42import { View } from "react-native-css/components" ;
53
@@ -9,75 +7,49 @@ const grandparentID = "grandparentID";
97const parentID = "parent" ;
108const childID = "child" ;
119
12- describe ( "on a primary input that hovers" , ( ) => {
13- beforeEach ( ( ) => {
14- if ( Platform . OS !== "ios" ) {
15- throw new Error ( "the suite runs on the iOS preset" ) ;
16- }
17- jest . spyOn ( Platform , "isMacCatalyst" , "get" ) . mockReturnValue ( true ) ;
18- } ) ;
19-
20- afterEach ( ( ) => {
21- jest . restoreAllMocks ( ) ;
22- } ) ;
23-
24- test ( "Styling based on parent state (group-{modifier})" , async ( ) => {
25- await render (
26- < View testID = { parentID } className = "group" >
27- < View testID = { childID } className = "group-hover:text-white" />
28- </ View > ,
29- ) ;
30-
31- const parent = screen . getByTestId ( parentID ) ;
32- const child = screen . getByTestId ( childID ) ;
33-
34- expect ( parent ) . not . toHaveStyle ( { color : "#fff" } ) ;
35- expect ( child ) . not . toHaveStyle ( { color : "#fff" } ) ;
36-
37- fireEvent ( parent , "hoverIn" ) ;
38-
39- expect ( child ) . toHaveStyle ( { color : "#fff" } ) ;
40- } ) ;
41-
42- test ( "Differentiating nested groups" , async ( ) => {
43- await render (
44- < View testID = { grandparentID } className = "group/grandparent" >
45- < View testID = { parentID } className = "group/parent" >
46- < View className = "group-hover/grandparent:text-white" />
47- < View testID = { childID } className = "group-hover/parent:text-white" />
48- </ View >
49- </ View > ,
50- ) ;
51-
52- const grandparent = screen . getByTestId ( grandparentID ) ;
53- const parent = screen . getByTestId ( parentID ) ;
54- const child = screen . getByTestId ( childID ) ;
55-
56- expect ( grandparent ) . not . toHaveStyle ( { color : "#fff" } ) ;
57- expect ( parent ) . not . toHaveStyle ( { color : "#fff" } ) ;
58- expect ( child ) . not . toHaveStyle ( { color : "#fff" } ) ;
10+ test ( "Styling based on parent state (group-{modifier})" , async ( ) => {
11+ await render (
12+ < View testID = { parentID } className = "group" >
13+ < View testID = { childID } className = "group-hover:text-white" />
14+ </ View > ,
15+ ) ;
5916
60- fireEvent ( grandparent , "hoverIn" ) ;
17+ const parent = screen . getByTestId ( parentID ) ;
18+ const child = screen . getByTestId ( childID ) ;
6119
62- expect ( child ) . not . toHaveStyle ( { color : "#fff" } ) ;
20+ expect ( parent ) . not . toHaveStyle ( { color : "#fff" } ) ;
21+ expect ( child ) . not . toHaveStyle ( { color : "#fff" } ) ;
6322
64- fireEvent ( parent , "hoverIn" ) ;
23+ fireEvent ( parent , "hoverIn" ) ;
6524
66- expect ( child ) . toHaveStyle ( { color : "#fff" } ) ;
67- } ) ;
25+ expect ( child ) . toHaveStyle ( { color : "#fff" } ) ;
6826} ) ;
6927
70- // Every hover comparison holds, as on main, so Tailwind's group-hover: applies on a touchscreen's platform too, as in Nativewind v4
71- test ( "group-hover applies on a touchscreen's platform" , async ( ) => {
28+ test ( "Differentiating nested groups" , async ( ) => {
7229 await render (
73- < View testID = { parentID } className = "group" >
74- < View testID = { childID } className = "group-hover:text-white" />
30+ < View testID = { grandparentID } className = "group/grandparent" >
31+ < View testID = { parentID } className = "group/parent" >
32+ < View className = "group-hover/grandparent:text-white" />
33+ < View testID = { childID } className = "group-hover/parent:text-white" />
34+ </ View >
7535 </ View > ,
7636 ) ;
7737
78- fireEvent ( screen . getByTestId ( parentID ) , "hoverIn" ) ;
38+ const grandparent = screen . getByTestId ( grandparentID ) ;
39+ const parent = screen . getByTestId ( parentID ) ;
40+ const child = screen . getByTestId ( childID ) ;
41+
42+ expect ( grandparent ) . not . toHaveStyle ( { color : "#fff" } ) ;
43+ expect ( parent ) . not . toHaveStyle ( { color : "#fff" } ) ;
44+ expect ( child ) . not . toHaveStyle ( { color : "#fff" } ) ;
45+
46+ fireEvent ( grandparent , "hoverIn" ) ;
7947
80- expect ( screen . getByTestId ( childID ) ) . toHaveStyle ( { color : "#fff" } ) ;
48+ expect ( child ) . not . toHaveStyle ( { color : "#fff" } ) ;
49+
50+ fireEvent ( parent , "hoverIn" ) ;
51+
52+ expect ( child ) . toHaveStyle ( { color : "#fff" } ) ;
8153} ) ;
8254
8355test ( "arbitrary groups - single className" , async ( ) => {
0 commit comments