1
1
import * as React from 'react' ;
2
- import { View , Text , TextInput } from 'react-native' ;
2
+ import { View , Text , TextInput , Switch } from 'react-native' ;
3
3
import { render } from '..' ;
4
4
5
5
/**
@@ -19,7 +19,6 @@ test('React Native API assumption: <View> renders single host element', () => {
19
19
20
20
test ( 'React Native API assumption: <Text> renders single host element' , ( ) => {
21
21
const view = render ( < Text testID = "test" > Hello</ Text > ) ;
22
- expect ( view . getByText ( 'Hello' ) ) . toBe ( view . getByTestId ( 'test' ) ) ;
23
22
24
23
expect ( view . toJSON ( ) ) . toMatchInlineSnapshot ( `
25
24
<Text
@@ -40,11 +39,6 @@ test('React Native API assumption: nested <Text> renders single host element', (
40
39
</ Text >
41
40
</ Text >
42
41
) ;
43
- expect ( view . getByText ( / H e l l o / ) ) . toBe ( view . getByTestId ( 'test' ) ) ;
44
- expect ( view . getByText ( 'Before' ) ) . toBe ( view . getByTestId ( 'before' ) ) ;
45
- expect ( view . getByText ( 'Deeply nested' ) ) . toBe (
46
- view . getByTestId ( 'deeplyNested' )
47
- ) ;
48
42
49
43
expect ( view . toJSON ( ) ) . toMatchInlineSnapshot ( `
50
44
<Text
@@ -78,10 +72,6 @@ test('React Native API assumption: <TextInput> renders single host element', ()
78
72
placeholder = "Placeholder"
79
73
/>
80
74
) ;
81
- expect ( view . getByPlaceholderText ( 'Placeholder' ) ) . toBe (
82
- view . getByTestId ( 'test' )
83
- ) ;
84
-
85
75
expect ( view . toJSON ( ) ) . toMatchInlineSnapshot ( `
86
76
<TextInput
87
77
defaultValue="default"
@@ -91,3 +81,27 @@ test('React Native API assumption: <TextInput> renders single host element', ()
91
81
/>
92
82
` ) ;
93
83
} ) ;
84
+
85
+ test ( 'React Native API assumption: <Switch> renders single host element' , ( ) => {
86
+ const view = render (
87
+ < Switch testID = "test" value = { true } onChange = { jest . fn ( ) } />
88
+ ) ;
89
+ expect ( view . getByTestId ( 'test' ) ) . toBe ( view . getByTestId ( 'test' ) ) ;
90
+
91
+ expect ( view . toJSON ( ) ) . toMatchInlineSnapshot ( `
92
+ <RCTSwitch
93
+ accessibilityRole="switch"
94
+ onChange={[Function]}
95
+ onResponderTerminationRequest={[Function]}
96
+ onStartShouldSetResponder={[Function]}
97
+ style={
98
+ {
99
+ "height": 31,
100
+ "width": 51,
101
+ }
102
+ }
103
+ testID="test"
104
+ value={true}
105
+ />
106
+ ` ) ;
107
+ } ) ;
0 commit comments