-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathreact-native-api.test.tsx
126 lines (113 loc) · 2.76 KB
/
react-native-api.test.tsx
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
125
126
import * as React from 'react';
import { View, Text, TextInput, Switch } from 'react-native';
import { render } from '..';
/**
* Tests in this file are intended to give us an proactive warning that React Native behavior has
* changed in a way that may impact our code like queries or event handling.
*/
test('React Native API assumption: <View> renders single host element', () => {
const view = render(<View testID="test" />);
expect(view.toJSON()).toMatchInlineSnapshot(`
<View
testID="test"
/>
`);
});
test('React Native API assumption: <Text> renders single host element', () => {
const view = render(<Text testID="test">Hello</Text>);
expect(view.toJSON()).toMatchInlineSnapshot(`
<Text
testID="test"
>
Hello
</Text>
`);
});
test('React Native API assumption: nested <Text> renders single host element', () => {
const view = render(
<Text testID="test">
<Text testID="before">Before</Text>
Hello
<Text testID="after">
<Text testID="deeplyNested">Deeply nested</Text>
</Text>
</Text>
);
expect(view.toJSON()).toMatchInlineSnapshot(`
<Text
testID="test"
>
<Text
testID="before"
>
Before
</Text>
Hello
<Text
testID="after"
>
<Text
testID="deeplyNested"
>
Deeply nested
</Text>
</Text>
</Text>
`);
});
test('React Native API assumption: <TextInput> renders single host element', () => {
const view = render(
<TextInput
testID="test"
defaultValue="default"
value="currentValue"
placeholder="Placeholder"
/>
);
expect(view.toJSON()).toMatchInlineSnapshot(`
<TextInput
defaultValue="default"
placeholder="Placeholder"
testID="test"
value="currentValue"
/>
`);
});
test('React Native API assumption: <TextInput> with nested Text renders single host element', () => {
const view = render(
<TextInput testID="test" placeholder="Placeholder">
<Text>Hello</Text>
</TextInput>
);
expect(view.toJSON()).toMatchInlineSnapshot(`
<TextInput
placeholder="Placeholder"
testID="test"
>
<Text>
Hello
</Text>
</TextInput>
`);
});
test('React Native API assumption: <Switch> renders single host element', () => {
const view = render(
<Switch testID="test" value={true} onChange={jest.fn()} />
);
expect(view.toJSON()).toMatchInlineSnapshot(`
<RCTSwitch
accessibilityRole="switch"
onChange={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
{
"height": 31,
"width": 51,
}
}
testID="test"
value={true}
/>
`);
});