-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathgrouping.test.tsx
More file actions
124 lines (92 loc) · 2.76 KB
/
grouping.test.tsx
File metadata and controls
124 lines (92 loc) · 2.76 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import { fireEvent, render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import { registerCSS } from "react-native-css/jest";
// import { getAnimatedStyle } from "react-native-reanimated";
const parentID = "parent";
const childID = "child";
jest.useFakeTimers();
test("groups", () => {
registerCSS(`
.group\\/item .my-class {
color: red;
}
`);
render(
<View testID={parentID} className="group/item will-change-container">
<View testID={childID} className="my-class" />
</View>,
);
const component = screen.getByTestId(childID);
expect(component.props.style).toStrictEqual({ color: "#f00" });
screen.rerender(
<View testID={parentID} className="will-change-container">
<View testID={childID} className="my-class" />
</View>,
);
expect(component.props.style).toStrictEqual(undefined);
});
test("group - active", () => {
registerCSS(
`.group\\/item:active .my-class {
background-color: red;
}`,
);
render(
<View testID={parentID} className="group/item">
<View testID={childID} className="my-class" />
</View>,
);
const parent = screen.getByTestId(parentID);
const child = screen.getByTestId(childID);
expect(child.props.style).toStrictEqual(undefined);
fireEvent(parent, "pressIn");
expect(child.props.style).toStrictEqual({ backgroundColor: "#f00" });
});
test.skip("group - active (animated)", () => {
registerCSS(`
.group\\/item:active .my-class {
color: red;
transition: color 1s;
}`);
render(
<View testID={parentID} className="group/item">
<View testID={childID} className="my-class" />
</View>,
);
const parent = screen.getByTestId(parentID);
const child = screen.getByTestId(childID);
expect(child.props.style).toStrictEqual(undefined);
fireEvent(parent, "pressIn");
jest.advanceTimersByTime(0);
// expect(getAnimatedStyle(child)).toStrictEqual({
// color: "rgba(0, 0, 0, 1)",
// });
jest.advanceTimersByTime(500);
// expect(getAnimatedStyle(child)).toStrictEqual({
// color: "rgba(151, 0, 0, 1)",
// });
jest.advanceTimersByTime(500);
// expect(getAnimatedStyle(child)).toStrictEqual({
// color: "rgba(255, 0, 0, 1)",
// });
});
test("group selector", () => {
registerCSS(
`.my-a.my-b .my-class {
color: red;
}`,
);
const { rerender } = render(
<View className="my-a my-b">
<View testID={childID} className="my-class" />
</View>,
);
const child = screen.getByTestId(childID);
expect(child.props.style).toStrictEqual({ color: "#f00" });
rerender(
<View className="my-b">
<View testID={childID} className="my-class" />
</View>,
);
expect(child.props.style).toStrictEqual(undefined);
});