@@ -24,19 +24,13 @@ afterEach(() => {
2424} ) ;
2525
2626test ( '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 (
3228 `${ VALIDATION_ERROR } . Detected attempt to render "hello" string within a <View> component.` ,
3329 ) ;
3430} ) ;
3531
3632test ( 'should throw an error when rerendering with text outside of Text component' , ( ) => {
37- render ( < View /> , {
38- unstable_validateStringsRenderedWithinText : true ,
39- } ) ;
33+ render ( < View /> ) ;
4034
4135 expect ( ( ) => screen . rerender ( < View > hello</ View > ) ) . toThrow (
4236 `${ VALIDATION_ERROR } . Detected attempt to render "hello" string within a <View> component.` ,
@@ -58,9 +52,7 @@ const InvalidTextAfterPress = () => {
5852} ;
5953
6054test ( 'should throw an error when strings are rendered outside Text' , ( ) => {
61- render ( < InvalidTextAfterPress /> , {
62- unstable_validateStringsRenderedWithinText : true ,
63- } ) ;
55+ render ( < InvalidTextAfterPress /> ) ;
6456
6557 expect ( ( ) => fireEvent . press ( screen . getByText ( 'Show text' ) ) ) . toThrow (
6658 `${ 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', () => {
7365 < Text >
7466 < > hello</ >
7567 </ Text > ,
76- { unstable_validateStringsRenderedWithinText : true } ,
7768 ) ,
7869 ) . not . toThrow ( ) ;
7970} ) ;
8071
81- // test('should not throw if option validateRenderedString is false', () => {
82- // expect(() => render(<View>hello</View>)).not.toThrow();
83- // });
84-
8572test ( `should throw when one of the children is a text and the parent is not a Text component` , ( ) => {
8673 expect ( ( ) =>
8774 render (
8875 < View >
8976 < Text > hello</ Text >
9077 hello
9178 </ View > ,
92- { unstable_validateStringsRenderedWithinText : true } ,
9379 ) ,
9480 ) . toThrow (
9581 `${ 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
10288 < View >
10389 < > hello</ >
10490 </ View > ,
105- { unstable_validateStringsRenderedWithinText : true } ,
10691 ) ,
10792 ) . toThrow (
10893 `${ VALIDATION_ERROR } . Detected attempt to render "hello" string within a <View> component.` ,
10994 ) ;
11095} ) ;
11196
11297test ( '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 (
11699 `${ VALIDATION_ERROR } . Detected attempt to render "0" string within a <View> component.` ,
117100 ) ;
118101} ) ;
@@ -125,7 +108,6 @@ test('should throw with components returning string value not rendered in Text',
125108 < View >
126109 < Trans i18nKey = "hello" />
127110 </ View > ,
128- { unstable_validateStringsRenderedWithinText : true } ,
129111 ) ,
130112 ) . toThrow (
131113 `${ 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',
138120 < Text >
139121 < Trans i18nKey = "hello" />
140122 </ Text > ,
141- { unstable_validateStringsRenderedWithinText : true } ,
142123 ) ,
143124 ) . not . toThrow ( ) ;
144125} ) ;
@@ -149,7 +130,6 @@ test('should throw when rendering string in a View in a Text', () => {
149130 < Text >
150131 < View > hello</ View >
151132 </ Text > ,
152- { unstable_validateStringsRenderedWithinText : true } ,
153133 ) ,
154134 ) . toThrow (
155135 `${ VALIDATION_ERROR } . Detected attempt to render "hello" string within a <View> component.` ,
@@ -175,7 +155,7 @@ const UseEffectComponent = () => {
175155} ;
176156
177157test ( 'should render immediate setState in useEffect properly' , async ( ) => {
178- render ( < UseEffectComponent /> , { unstable_validateStringsRenderedWithinText : true } ) ;
158+ render ( < UseEffectComponent /> ) ;
179159
180160 expect ( await screen . findByText ( 'Text is visible' ) ) . toBeTruthy ( ) ;
181161} ) ;
@@ -195,9 +175,7 @@ const InvalidUseEffectComponent = () => {
195175} ;
196176
197177test ( 'should throw properly for immediate setState in useEffect' , ( ) => {
198- expect ( ( ) =>
199- render ( < InvalidUseEffectComponent /> , { unstable_validateStringsRenderedWithinText : true } ) ,
200- ) . toThrow (
178+ expect ( ( ) => render ( < InvalidUseEffectComponent /> ) ) . toThrow (
201179 `${ VALIDATION_ERROR } . Detected attempt to render "Text is visible" string within a <View> component.` ,
202180 ) ;
203181} ) ;
0 commit comments