Skip to content

Commit e8db784

Browse files
committed
Preserver line break
1 parent 4b417f1 commit e8db784

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/index.spec.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ describe('reactElementToJSXString(ReactElement)', () => {
285285

286286
it('reactElementToJSXString(<div z="3" a="1" b="2"/>, {sortProps: false})', () => {
287287
/* eslint react/jsx-sort-props: 0 */
288-
289288
expect(
290289
reactElementToJSXString(<div z="3" a="1" b="2" />, {
291290
sortProps: false,
@@ -923,20 +922,20 @@ describe('reactElementToJSXString(ReactElement)', () => {
923922
'<This should take precedence />'
924923
);
925924
});
925+
926926
// maxInlineAttributesLineLength tests
927927
// Validate two props will stay inline if their length is less than the option
928-
929928
it('reactElementToJSXString(<div aprop="1" bprop="2" />, { maxInlineAttributesLineLength: 100 }))', () => {
930929
expect(
931930
reactElementToJSXString(<div aprop="1" bprop="2" />, {
932931
maxInlineAttributesLineLength: 100,
933932
})
934933
).toEqual('<div aprop="1" bprop="2" />');
935934
});
935+
936936
// Validate one prop will go to new line if length is greater than option. One prop is a special case since
937937
// the old logic operated on whether or not two or more attributes were present. Making sure this overrides
938938
// that older logic
939-
940939
it('reactElementToJSXString(<div aprop="1"/>, { maxInlineAttributesLineLength: 5 }))', () => {
941940
expect(
942941
reactElementToJSXString(<div aprop="1" />, {
@@ -946,8 +945,8 @@ describe('reactElementToJSXString(ReactElement)', () => {
946945
aprop="1"
947946
/>`);
948947
});
949-
// Validate two props will go be multiline if their length is greater than the given option
950948

949+
// Validate two props will go be multiline if their length is greater than the given option
951950
it('reactElementToJSXString(<div aprop="1" bprop="2" />, { maxInlineAttributesLineLength: 10 }))', () => {
952951
expect(
953952
reactElementToJSXString(<div aprop="1" bprop="2" />, {
@@ -958,9 +957,9 @@ describe('reactElementToJSXString(ReactElement)', () => {
958957
bprop="2"
959958
/>`);
960959
});
960+
961961
// Same tests as above but with elements that have children. The closing braces for elements with children and without children
962962
// run through different code paths so we have both sets of test to specify the behavior of both when this option is present
963-
964963
it('reactElementToJSXString(<div aprop="1" bprop="2">content</div>, { maxInlineAttributesLineLength: 100 }))', () => {
965964
expect(
966965
reactElementToJSXString(
@@ -1005,8 +1004,8 @@ describe('reactElementToJSXString(ReactElement)', () => {
10051004
content
10061005
</div>`);
10071006
});
1008-
// Multi-level inline attribute test
10091007

1008+
// Multi-level inline attribute test
10101009
it('reactElementToJSXString(<div><div>content</div></div>, { maxInlineAttributesLineLength: 24 }))', () => {
10111010
expect(
10121011
reactElementToJSXString(
@@ -1040,9 +1039,7 @@ describe('reactElementToJSXString(ReactElement)', () => {
10401039

10411040
it('sends the original fn to functionValue', () => {
10421041
const fn = () => {};
1043-
10441042
const functionValue = (receivedFn) => expect(receivedFn).toBe(fn);
1045-
10461043
reactElementToJSXString(<div fn={fn} />, {
10471044
functionValue,
10481045
});
@@ -1119,7 +1116,9 @@ describe('reactElementToJSXString(ReactElement)', () => {
11191116
}}
11201117
/>
11211118
);
1119+
11221120
const insideString = reactElementToJSXString(inside);
1121+
11231122
return (
11241123
<div>
11251124
{insideString}
@@ -1254,7 +1253,6 @@ describe('reactElementToJSXString(ReactElement)', () => {
12541253

12551254
it('should stringify `Suspense` correctly', () => {
12561255
const Spinner = () => null;
1257-
12581256
const ProfilePage = () => null;
12591257

12601258
expect(
@@ -1287,7 +1285,6 @@ describe('reactElementToJSXString(ReactElement)', () => {
12871285

12881286
it('should stringify `Contex.Provider` correctly', () => {
12891287
const Ctx = React.createContext();
1290-
12911288
const App = () => {};
12921289

12931290
expect(
@@ -1335,7 +1332,6 @@ describe('reactElementToJSXString(ReactElement)', () => {
13351332

13361333
it('should stringify `Contex.Consumer` correctly', () => {
13371334
const Ctx = React.createContext();
1338-
13391335
const Button = () => null;
13401336

13411337
expect(

0 commit comments

Comments
 (0)