-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathupgrading.test.tsx
More file actions
76 lines (60 loc) · 2.18 KB
/
upgrading.test.tsx
File metadata and controls
76 lines (60 loc) · 2.18 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
import { Text } from "react-native-css/components/Text";
import { View } from "react-native-css/components/View";
import { registerCSS, render, screen } from "react-native-css/jest";
const parentID = "parent";
const childID = "child";
const log = jest.fn();
beforeAll(() => {
jest.spyOn(console, "log").mockImplementation(log);
});
beforeEach(() => {
log.mockClear();
});
test("adding a group", () => {
registerCSS(
`.group .my-class {
color: red;
}`,
);
render(
<View testID={parentID}>
<Text testID={childID} className="my-class" />
</View>,
);
const child = screen.getByTestId(childID);
expect(child.props.style).toStrictEqual(undefined);
screen.rerender(
<View testID={parentID} className="group">
<Text testID={childID} className="my-class" />
</View>,
);
expect(log.mock.calls).toEqual([
[
"ReactNativeCss: className 'group' added a container after the initial render. This causes the components state to be reset and all children be re-mounted. This will cause unexpected behavior. Use the className 'will-change-container' to avoid this warning. If this was caused by sibling components being added/removed, use a 'key' prop so React can track the component correctly.",
],
]);
});
test.only("will-change-container", () => {
registerCSS(
`.group .my-class {
color: red;
}`,
);
render(
<View testID={parentID} className="will-change-container">
<Text testID={childID} className="my-class" />
</View>,
);
const child = screen.getByTestId(childID);
expect(child.props.style).toStrictEqual(undefined);
screen.rerender(
<View testID={parentID} className="group">
<Text testID={childID} className="my-class" />
</View>,
);
expect(log.mock.calls).toEqual([
[
"ReactNativeCss: className 'group' added or removed a container after the initial render. This causes the components state to be reset and all children be re-mounted. This will cause unexpected behavior. Use the className 'will-change-container' to avoid this warning. If this was caused by sibling components being added/removed, use a 'key' prop so React can track the component correctly.",
],
]);
});