3
3
*/
4
4
5
5
/* eslint-disable react/no-string-refs */
6
+
6
7
import React , { Fragment , Component } from 'react' ;
7
8
import { createRenderer } from 'react-test-renderer/shallow' ;
8
9
import { mount } from 'enzyme' ;
@@ -284,7 +285,6 @@ describe('reactElementToJSXString(ReactElement)', () => {
284
285
285
286
it ( 'reactElementToJSXString(<div z="3" a="1" b="2"/>, {sortProps: false})' , ( ) => {
286
287
/* eslint react/jsx-sort-props: 0 */
287
-
288
288
expect (
289
289
reactElementToJSXString ( < div z = "3" a = "1" b = "2" /> , {
290
290
sortProps : false ,
@@ -692,7 +692,6 @@ describe('reactElementToJSXString(ReactElement)', () => {
692
692
) ;
693
693
}
694
694
}
695
-
696
695
MyDecorator . displayName = `${ ComposedComponent . name } -Decorated` ;
697
696
return MyDecorator ;
698
697
}
@@ -963,20 +962,20 @@ describe('reactElementToJSXString(ReactElement)', () => {
963
962
'<This should take precedence />'
964
963
) ;
965
964
} ) ;
965
+
966
966
// maxInlineAttributesLineLength tests
967
967
// Validate two props will stay inline if their length is less than the option
968
-
969
968
it ( 'reactElementToJSXString(<div aprop="1" bprop="2" />, { maxInlineAttributesLineLength: 100 }))' , ( ) => {
970
969
expect (
971
970
reactElementToJSXString ( < div aprop = "1" bprop = "2" /> , {
972
971
maxInlineAttributesLineLength : 100 ,
973
972
} )
974
973
) . toEqual ( '<div aprop="1" bprop="2" />' ) ;
975
974
} ) ;
975
+
976
976
// Validate one prop will go to new line if length is greater than option. One prop is a special case since
977
977
// the old logic operated on whether or not two or more attributes were present. Making sure this overrides
978
978
// that older logic
979
-
980
979
it ( 'reactElementToJSXString(<div aprop="1"/>, { maxInlineAttributesLineLength: 5 }))' , ( ) => {
981
980
expect (
982
981
reactElementToJSXString ( < div aprop = "1" /> , {
@@ -986,8 +985,8 @@ describe('reactElementToJSXString(ReactElement)', () => {
986
985
aprop="1"
987
986
/>` ) ;
988
987
} ) ;
989
- // Validate two props will go be multiline if their length is greater than the given option
990
988
989
+ // Validate two props will go be multiline if their length is greater than the given option
991
990
it ( 'reactElementToJSXString(<div aprop="1" bprop="2" />, { maxInlineAttributesLineLength: 10 }))' , ( ) => {
992
991
expect (
993
992
reactElementToJSXString ( < div aprop = "1" bprop = "2" /> , {
@@ -998,9 +997,9 @@ describe('reactElementToJSXString(ReactElement)', () => {
998
997
bprop="2"
999
998
/>` ) ;
1000
999
} ) ;
1000
+
1001
1001
// Same tests as above but with elements that have children. The closing braces for elements with children and without children
1002
1002
// run through different code paths so we have both sets of test to specify the behavior of both when this option is present
1003
-
1004
1003
it ( 'reactElementToJSXString(<div aprop="1" bprop="2">content</div>, { maxInlineAttributesLineLength: 100 }))' , ( ) => {
1005
1004
expect (
1006
1005
reactElementToJSXString (
@@ -1045,8 +1044,8 @@ describe('reactElementToJSXString(ReactElement)', () => {
1045
1044
content
1046
1045
</div>` ) ;
1047
1046
} ) ;
1048
- // Multi-level inline attribute test
1049
1047
1048
+ // Multi-level inline attribute test
1050
1049
it ( 'reactElementToJSXString(<div><div>content</div></div>, { maxInlineAttributesLineLength: 24 }))' , ( ) => {
1051
1050
expect (
1052
1051
reactElementToJSXString (
@@ -1080,9 +1079,7 @@ describe('reactElementToJSXString(ReactElement)', () => {
1080
1079
1081
1080
it ( 'sends the original fn to functionValue' , ( ) => {
1082
1081
const fn = ( ) => { } ;
1083
-
1084
1082
const functionValue = ( receivedFn ) => expect ( receivedFn ) . toBe ( fn ) ;
1085
-
1086
1083
reactElementToJSXString ( < div fn = { fn } /> , {
1087
1084
functionValue,
1088
1085
} ) ;
@@ -1159,7 +1156,9 @@ describe('reactElementToJSXString(ReactElement)', () => {
1159
1156
} }
1160
1157
/>
1161
1158
) ;
1159
+
1162
1160
const insideString = reactElementToJSXString ( inside ) ;
1161
+
1163
1162
return (
1164
1163
< div >
1165
1164
{ insideString }
@@ -1285,7 +1284,6 @@ describe('reactElementToJSXString(ReactElement)', () => {
1285
1284
1286
1285
it ( 'should stringify `Suspense` correctly' , ( ) => {
1287
1286
const Spinner = ( ) => null ;
1288
-
1289
1287
const ProfilePage = ( ) => null ;
1290
1288
1291
1289
expect (
@@ -1318,7 +1316,6 @@ describe('reactElementToJSXString(ReactElement)', () => {
1318
1316
1319
1317
it ( 'should stringify `Contex.Provider` correctly' , ( ) => {
1320
1318
const Ctx = React . createContext ( ) ;
1321
-
1322
1319
const App = ( ) => { } ;
1323
1320
1324
1321
expect (
@@ -1351,7 +1348,6 @@ describe('reactElementToJSXString(ReactElement)', () => {
1351
1348
1352
1349
it ( 'should stringify `Contex.Consumer` correctly' , ( ) => {
1353
1350
const Ctx = React . createContext ( ) ;
1354
-
1355
1351
const Button = ( ) => null ;
1356
1352
1357
1353
expect (
0 commit comments