-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathselectors.test.tsx
More file actions
70 lines (51 loc) · 1.58 KB
/
selectors.test.tsx
File metadata and controls
70 lines (51 loc) · 1.58 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
import { act, render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import { registerCSS, testID } from "react-native-css/jest";
import { colorScheme } from "react-native-css/runtime";
test.skip(":is(.dark *)", () => {
registerCSS(`@cssInterop set darkMode class dark;
.my-class:is(.dark *) { color: red; }`);
render(<View testID={testID} className="my-class" />);
const component = screen.getByTestId(testID);
expect(component.props.style).toStrictEqual(undefined);
act(() => {
colorScheme.set("dark");
});
expect(component.props.style).toStrictEqual({ color: "#f00" });
});
test.skip(':root[class="dark"]', () => {
registerCSS(`@cssInterop set darkMode class dark;
:root[class="dark"] {
--my-var: red;
}
.my-class {
color: var(--my-var);
}`);
render(<View testID={testID} className="my-class" />);
const component = screen.getByTestId(testID);
expect(component.props.style).toStrictEqual({});
act(() => {
colorScheme.set("dark");
});
expect(component.props.style).toStrictEqual({ color: "red" });
});
test.skip(':root[class~="dark"]', () => {
registerCSS(`
@react-native {
darkMode: dark;
}
:root[class~="dark"] {
--my-var: red;
}
.my-class {
color: var(--my-var);
}
`);
render(<View testID={testID} className="my-class" />);
const component = screen.getByTestId(testID);
expect(component.props.style).toStrictEqual({});
act(() => {
colorScheme.set("dark");
});
expect(component.props.style).toStrictEqual({ color: "red" });
});