@@ -24,19 +24,13 @@ afterEach(() => {
24
24
} ) ;
25
25
26
26
test ( 'should throw when rendering a string outside a text component' , ( ) => {
27
- expect ( ( ) =>
28
- render ( < View > hello</ View > , {
29
- unstable_validateStringsRenderedWithinText : true ,
30
- } ) ,
31
- ) . toThrow (
27
+ expect ( ( ) => render ( < View > hello</ View > ) ) . toThrow (
32
28
`${ VALIDATION_ERROR } . Detected attempt to render "hello" string within a <View> component.` ,
33
29
) ;
34
30
} ) ;
35
31
36
32
test ( 'should throw an error when rerendering with text outside of Text component' , ( ) => {
37
- render ( < View /> , {
38
- unstable_validateStringsRenderedWithinText : true ,
39
- } ) ;
33
+ render ( < View /> ) ;
40
34
41
35
expect ( ( ) => screen . rerender ( < View > hello</ View > ) ) . toThrow (
42
36
`${ VALIDATION_ERROR } . Detected attempt to render "hello" string within a <View> component.` ,
@@ -58,9 +52,7 @@ const InvalidTextAfterPress = () => {
58
52
} ;
59
53
60
54
test ( 'should throw an error when strings are rendered outside Text' , ( ) => {
61
- render ( < InvalidTextAfterPress /> , {
62
- unstable_validateStringsRenderedWithinText : true ,
63
- } ) ;
55
+ render ( < InvalidTextAfterPress /> ) ;
64
56
65
57
expect ( ( ) => fireEvent . press ( screen . getByText ( 'Show text' ) ) ) . toThrow (
66
58
`${ VALIDATION_ERROR } . Detected attempt to render "text rendered outside text component" string within a <View> component.` ,
@@ -73,23 +65,17 @@ test('should not throw for texts nested in fragments', () => {
73
65
< Text >
74
66
< > hello</ >
75
67
</ Text > ,
76
- { unstable_validateStringsRenderedWithinText : true } ,
77
68
) ,
78
69
) . not . toThrow ( ) ;
79
70
} ) ;
80
71
81
- // test('should not throw if option validateRenderedString is false', () => {
82
- // expect(() => render(<View>hello</View>)).not.toThrow();
83
- // });
84
-
85
72
test ( `should throw when one of the children is a text and the parent is not a Text component` , ( ) => {
86
73
expect ( ( ) =>
87
74
render (
88
75
< View >
89
76
< Text > hello</ Text >
90
77
hello
91
78
</ View > ,
92
- { unstable_validateStringsRenderedWithinText : true } ,
93
79
) ,
94
80
) . toThrow (
95
81
`${ VALIDATION_ERROR } . Detected attempt to render "hello" string within a <View> component.` ,
@@ -102,17 +88,14 @@ test(`should throw when a string is rendered within a fragment rendered outside
102
88
< View >
103
89
< > hello</ >
104
90
</ View > ,
105
- { unstable_validateStringsRenderedWithinText : true } ,
106
91
) ,
107
92
) . toThrow (
108
93
`${ VALIDATION_ERROR } . Detected attempt to render "hello" string within a <View> component.` ,
109
94
) ;
110
95
} ) ;
111
96
112
97
test ( 'should throw if a number is rendered outside a text' , ( ) => {
113
- expect ( ( ) =>
114
- render ( < View > 0</ View > , { unstable_validateStringsRenderedWithinText : true } ) ,
115
- ) . toThrow (
98
+ expect ( ( ) => render ( < View > 0</ View > ) ) . toThrow (
116
99
`${ VALIDATION_ERROR } . Detected attempt to render "0" string within a <View> component.` ,
117
100
) ;
118
101
} ) ;
@@ -125,7 +108,6 @@ test('should throw with components returning string value not rendered in Text',
125
108
< View >
126
109
< Trans i18nKey = "hello" />
127
110
</ View > ,
128
- { unstable_validateStringsRenderedWithinText : true } ,
129
111
) ,
130
112
) . toThrow (
131
113
`${ VALIDATION_ERROR } . Detected attempt to render "hello" string within a <View> component.` ,
@@ -138,7 +120,6 @@ test('should not throw with components returning string value rendered in Text',
138
120
< Text >
139
121
< Trans i18nKey = "hello" />
140
122
</ Text > ,
141
- { unstable_validateStringsRenderedWithinText : true } ,
142
123
) ,
143
124
) . not . toThrow ( ) ;
144
125
} ) ;
@@ -149,7 +130,6 @@ test('should throw when rendering string in a View in a Text', () => {
149
130
< Text >
150
131
< View > hello</ View >
151
132
</ Text > ,
152
- { unstable_validateStringsRenderedWithinText : true } ,
153
133
) ,
154
134
) . toThrow (
155
135
`${ VALIDATION_ERROR } . Detected attempt to render "hello" string within a <View> component.` ,
@@ -175,7 +155,7 @@ const UseEffectComponent = () => {
175
155
} ;
176
156
177
157
test ( 'should render immediate setState in useEffect properly' , async ( ) => {
178
- render ( < UseEffectComponent /> , { unstable_validateStringsRenderedWithinText : true } ) ;
158
+ render ( < UseEffectComponent /> ) ;
179
159
180
160
expect ( await screen . findByText ( 'Text is visible' ) ) . toBeTruthy ( ) ;
181
161
} ) ;
@@ -195,9 +175,7 @@ const InvalidUseEffectComponent = () => {
195
175
} ;
196
176
197
177
test ( 'should throw properly for immediate setState in useEffect' , ( ) => {
198
- expect ( ( ) =>
199
- render ( < InvalidUseEffectComponent /> , { unstable_validateStringsRenderedWithinText : true } ) ,
200
- ) . toThrow (
178
+ expect ( ( ) => render ( < InvalidUseEffectComponent /> ) ) . toThrow (
201
179
`${ VALIDATION_ERROR } . Detected attempt to render "Text is visible" string within a <View> component.` ,
202
180
) ;
203
181
} ) ;
0 commit comments