Skip to content

Commit 204e46c

Browse files
chrisbujokcpojer
authored andcommitted
Put JSX closing brackets in new line in snapshots (#2832)
1 parent 9bdb555 commit 204e46c

File tree

10 files changed

+84
-47
lines changed

10 files changed

+84
-47
lines changed

examples/react-native/__tests__/__snapshots__/Intro-test.js.snap

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ exports[`test renders correctly 1`] = `
77
"flex": 1,
88
"justifyContent": "center",
99
}
10-
}>
10+
}
11+
>
1112
<Text
1213
accessible={true}
1314
allowFontScaling={true}
@@ -18,7 +19,8 @@ exports[`test renders correctly 1`] = `
1819
"margin": 10,
1920
"textAlign": "center",
2021
}
21-
}>
22+
}
23+
>
2224
Welcome to React Native!
2325
</Text>
2426
<Text
@@ -31,7 +33,8 @@ exports[`test renders correctly 1`] = `
3133
"marginBottom": 5,
3234
"textAlign": "center",
3335
}
34-
}>
36+
}
37+
>
3538
This is a React Native snapshot test.
3639
</Text>
3740
</View>
@@ -42,7 +45,8 @@ exports[`test renders the ActivityIndicator component 1`] = `
4245
animating={true}
4346
color="#999999"
4447
hidesWhenStopped={true}
45-
size="small" />
48+
size="small"
49+
/>
4650
`;
4751

4852
exports[`test renders the Image component 1`] = `
@@ -52,7 +56,8 @@ exports[`test renders the Image component 1`] = `
5256
"height": 240,
5357
"width": 320,
5458
}
55-
} />
59+
}
60+
/>
5661
`;
5762

5863
exports[`test renders the ListView component 1`] = `
@@ -76,23 +81,27 @@ exports[`test renders the ListView component 1`] = `
7681
renderRow={[Function]}
7782
scrollEventThrottle={50}
7883
scrollRenderAheadDistance={1000}
79-
stickyHeaderIndices={Array []}>
84+
stickyHeaderIndices={Array []}
85+
>
8086
<Text
8187
accessible={true}
8288
allowFontScaling={true}
83-
ellipsizeMode="tail">
89+
ellipsizeMode="tail"
90+
>
8491
apple
8592
</Text>
8693
<Text
8794
accessible={true}
8895
allowFontScaling={true}
89-
ellipsizeMode="tail">
96+
ellipsizeMode="tail"
97+
>
9098
banana
9199
</Text>
92100
<Text
93101
accessible={true}
94102
allowFontScaling={true}
95-
ellipsizeMode="tail">
103+
ellipsizeMode="tail"
104+
>
96105
kiwi
97106
</Text>
98107
</ScrollView>
@@ -101,5 +110,6 @@ exports[`test renders the ListView component 1`] = `
101110
exports[`test renders the TextInput component 1`] = `
102111
<TextInput
103112
autoCorrect={false}
104-
value="apple banana kiwi" />
113+
value="apple banana kiwi"
114+
/>
105115
`;

examples/snapshot/__tests__/__snapshots__/Link.react-test.js.snap

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ exports[`test changes the class when hovered 1`] = `
33
className="normal"
44
href="http://www.facebook.com"
55
onMouseEnter={[Function]}
6-
onMouseLeave={[Function]}>
6+
onMouseLeave={[Function]}
7+
>
78
Facebook
89
</a>
910
`;
@@ -13,7 +14,8 @@ exports[`test changes the class when hovered 2`] = `
1314
className="hovered"
1415
href="http://www.facebook.com"
1516
onMouseEnter={[Function]}
16-
onMouseLeave={[Function]}>
17+
onMouseLeave={[Function]}
18+
>
1719
Facebook
1820
</a>
1921
`;
@@ -23,7 +25,8 @@ exports[`test changes the class when hovered 3`] = `
2325
className="normal"
2426
href="http://www.facebook.com"
2527
onMouseEnter={[Function]}
26-
onMouseLeave={[Function]}>
28+
onMouseLeave={[Function]}
29+
>
2730
Facebook
2831
</a>
2932
`;
@@ -33,7 +36,8 @@ exports[`test properly escapes quotes 1`] = `
3336
className="normal"
3437
href="#"
3538
onMouseEnter={[Function]}
36-
onMouseLeave={[Function]}>
39+
onMouseLeave={[Function]}
40+
>
3741
"Facebook" \\'is \\ 'awesome'
3842
</a>
3943
`;
@@ -43,7 +47,8 @@ exports[`test renders as an anchor when no page is set 1`] = `
4347
className="normal"
4448
href="#"
4549
onMouseEnter={[Function]}
46-
onMouseLeave={[Function]}>
50+
onMouseLeave={[Function]}
51+
>
4752
Facebook
4853
</a>
4954
`;
@@ -53,7 +58,8 @@ exports[`test renders correctly 1`] = `
5358
className="normal"
5459
href="http://www.facebook.com"
5560
onMouseEnter={[Function]}
56-
onMouseLeave={[Function]}>
61+
onMouseLeave={[Function]}
62+
>
5763
Facebook
5864
</a>
5965
`;

integration_tests/__tests__/__snapshots__/snapshot-serializers-test.js.snap

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ exports[`Snapshot serializers renders snapshot 1`] = `
22
Object {
33
"snapshot serializers works with default serializers 1": "
44
<div
5-
id=\\"foo\\" />
5+
id=\\"foo\\"
6+
/>
67
",
78
"snapshot serializers works with first plugin 1": "foo: 1",
89
"snapshot serializers works with nested serializable objects 1": "foo: bar: 2",
@@ -13,7 +14,8 @@ Object {
1314
\\"a\\": 6,
1415
}
1516
}
16-
bProp={foo: 8} />
17+
bProp={foo: 8}
18+
/>
1719
",
1820
"snapshot serializers works with prepended plugins from expect method called once 1": "
1921
<div
@@ -22,7 +24,8 @@ Object {
2224
\\"a\\": 6,
2325
}
2426
}
25-
bProp={Foo: 8} />
27+
bProp={Foo: 8}
28+
/>
2629
",
2730
"snapshot serializers works with prepended plugins from expect method called twice 1": "
2831
<div
@@ -31,7 +34,8 @@ Object {
3134
\\"a\\": 6,
3235
}
3336
}
34-
bProp={FOO: 8} />
37+
bProp={FOO: 8}
38+
/>
3539
",
3640
"snapshot serializers works with second plugin 1": "bar: 2",
3741
}

integration_tests/transform/multiple-transformers/__tests__/__snapshots__/multiple-transformers-test.js.snap

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
exports[`test generates a snapshot with correctly transformed dependencies 1`] = `
22
<div
3-
className="App-root">
3+
className="App-root"
4+
>
45
<div
5-
className="App-header">
6+
className="App-header"
7+
>
68
<img
79
alt="logo"
810
className="App-logo"
9-
src="logo.svg" />
11+
src="logo.svg"
12+
/>
1013
<h2
11-
className={undefined}>
14+
className={undefined}
15+
>
1216
Welcome to React
1317
</h2>
1418
</div>
1519
<p
16-
className="App-intro">
20+
className="App-intro"
21+
>
1722
To get started, edit
1823
<code>
1924
src/App.js

packages/jest-diff/src/__tests__/diff-test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ test('React elements', () => {
150150
},
151151
type: 'div',
152152
});
153-
expect(stripAnsi(result)).toMatch(/<div[\s\S]+className="fun">/);
153+
expect(stripAnsi(result)).toMatch(/<div\n/);
154+
expect(stripAnsi(result)).toMatch(/[\s\S]+className="fun"\n/);
155+
expect(stripAnsi(result)).toMatch(/>/);
154156
expect(stripAnsi(result)).toMatch(/\-\s+Hello/);
155157
expect(stripAnsi(result)).toMatch(/\+\s+Goodbye/);
156158
});

packages/pretty-format/src/__tests__/__snapshots__/pretty-format-test.js.snap

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ exports[`prettyFormat() ReactTestComponent and ReactElement plugins ReactElement
77
rat
88
</span>
99
</div>
10-
} />"
10+
}
11+
/>"
1112
`;
1213
1314
exports[`prettyFormat() ReactTestComponent and ReactElement plugins ReactTestComponent plugin highlights syntax 1`] = `
@@ -19,5 +20,6 @@ exports[`prettyFormat() ReactTestComponent and ReactElement plugins ReactTestCom
1920
rat
2021
</span>
2122
</div>
22-
} />"
23+
}
24+
/>"
2325
`;

packages/pretty-format/src/__tests__/pretty-format-test.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -416,28 +416,28 @@ describe('prettyFormat()', () => {
416416
it('supports props with strings', () => {
417417
assertPrintedJSX(
418418
React.createElement('Mouse', {style: 'color:red'}),
419-
'<Mouse\n style="color:red" />'
419+
'<Mouse\n style="color:red"\n/>'
420420
);
421421
});
422422

423423
it('supports props with numbers', () => {
424424
assertPrintedJSX(
425425
React.createElement('Mouse', {size: 5}),
426-
'<Mouse\n size={5} />'
426+
'<Mouse\n size={5}\n/>'
427427
);
428428
});
429429

430430
it('supports a single element with a function prop', () => {
431431
assertPrintedJSX(
432432
React.createElement('Mouse', {onclick: function onclick() {}}),
433-
'<Mouse\n onclick={[Function onclick]} />'
433+
'<Mouse\n onclick={[Function onclick]}\n/>'
434434
);
435435
});
436436

437437
it('supports a single element with a object prop', () => {
438438
assertPrintedJSX(
439439
React.createElement('Mouse', {customProp: {one: '1', two: 2}}),
440-
'<Mouse\n customProp={\n Object {\n "one": "1",\n "two": 2,\n }\n } />'
440+
'<Mouse\n customProp={\n Object {\n "one": "1",\n "two": 2,\n }\n }\n/>'
441441
);
442442
});
443443

@@ -446,7 +446,7 @@ describe('prettyFormat()', () => {
446446
React.createElement('Mouse', {customProp: {one: '1', two: 2}},
447447
React.createElement('Mouse')
448448
),
449-
'<Mouse\n customProp={\n Object {\n "one": "1",\n "two": 2,\n }\n }>\n <Mouse />\n</Mouse>'
449+
'<Mouse\n customProp={\n Object {\n "one": "1",\n "two": 2,\n }\n }\n>\n <Mouse />\n</Mouse>'
450450
);
451451
});
452452

@@ -456,7 +456,7 @@ describe('prettyFormat()', () => {
456456
'HELLO',
457457
React.createElement('Mouse'), 'CIAO'
458458
),
459-
'<Mouse\n customProp={\n Object {\n "one": "1",\n "two": 2,\n }\n }\n onclick={[Function onclick]}>\n HELLO\n <Mouse />\n CIAO\n</Mouse>'
459+
'<Mouse\n customProp={\n Object {\n "one": "1",\n "two": 2,\n }\n }\n onclick={[Function onclick]}\n>\n HELLO\n <Mouse />\n CIAO\n</Mouse>'
460460
);
461461
});
462462

@@ -482,7 +482,7 @@ describe('prettyFormat()', () => {
482482
),
483483
'CIAO'
484484
),
485-
'<Mouse\n customProp={\n Object {\n "one": "1",\n "two": 2,\n }\n }\n onclick={[Function onclick]}>\n HELLO\n <Mouse\n customProp={\n Object {\n "one": "1",\n "two": 2,\n }\n }\n onclick={[Function onclick]}>\n HELLO\n <Mouse />\n CIAO\n </Mouse>\n CIAO\n</Mouse>'
485+
'<Mouse\n customProp={\n Object {\n "one": "1",\n "two": 2,\n }\n }\n onclick={[Function onclick]}\n>\n HELLO\n <Mouse\n customProp={\n Object {\n "one": "1",\n "two": 2,\n }\n }\n onclick={[Function onclick]}\n >\n HELLO\n <Mouse />\n CIAO\n </Mouse>\n CIAO\n</Mouse>'
486486
);
487487
});
488488

@@ -510,7 +510,7 @@ describe('prettyFormat()', () => {
510510
'NESTED'
511511
)
512512
),
513-
'<Mouse\n abc={\n Object {\n "one": "1",\n "two": 2,\n }\n }\n zeus="kentaromiura watched me fix this">\n <Mouse\n acbd={\n Object {\n "one": "1",\n "two": 2,\n }\n }\n xyz={123}>\n NESTED\n </Mouse>\n</Mouse>'
513+
'<Mouse\n abc={\n Object {\n "one": "1",\n "two": 2,\n }\n }\n zeus="kentaromiura watched me fix this"\n>\n <Mouse\n acbd={\n Object {\n "one": "1",\n "two": 2,\n }\n }\n xyz={123}\n >\n NESTED\n </Mouse>\n</Mouse>'
514514
);
515515
/* eslint-enable sort-keys */
516516
});
@@ -520,7 +520,7 @@ describe('prettyFormat()', () => {
520520
React.createElement('Mouse', {
521521
prop: React.createElement('div'),
522522
}),
523-
'<Mouse\n prop={<div />} />'
523+
'<Mouse\n prop={<div />}\n/>'
524524
);
525525
});
526526

@@ -529,7 +529,7 @@ describe('prettyFormat()', () => {
529529
React.createElement('Mouse', {
530530
prop: React.createElement('div', {foo: 'bar'}),
531531
}),
532-
'<Mouse\n prop={\n <div\n foo="bar" />\n } />'
532+
'<Mouse\n prop={\n <div\n foo="bar"\n />\n }\n/>'
533533
);
534534
});
535535

@@ -541,7 +541,7 @@ describe('prettyFormat()', () => {
541541
React.createElement('Mouse', {
542542
prop: React.createElement(Cat, {foo: 'bar'}),
543543
}),
544-
'<Mouse\n prop={\n <Cat\n foo="bar" />\n } />'
544+
'<Mouse\n prop={\n <Cat\n foo="bar"\n />\n }\n/>'
545545
);
546546
});
547547

@@ -553,7 +553,7 @@ describe('prettyFormat()', () => {
553553
React.createElement('Mouse', {
554554
prop: React.createElement(Cat, {}, React.createElement('div')),
555555
}),
556-
'<Mouse\n prop={\n <Cat>\n <div />\n </Cat>\n } />'
556+
'<Mouse\n prop={\n <Cat>\n <div />\n </Cat>\n }\n/>'
557557
);
558558
});
559559

@@ -562,7 +562,7 @@ describe('prettyFormat()', () => {
562562
React.createElement('Mouse', {
563563
prop: React.createElement('div', null, 'mouse'),
564564
}),
565-
'<Mouse\n prop={\n <div>\n mouse\n </div>\n } />'
565+
'<Mouse\n prop={\n <div>\n mouse\n </div>\n }\n/>'
566566
);
567567
});
568568

@@ -571,7 +571,7 @@ describe('prettyFormat()', () => {
571571
React.createElement('Mouse', {
572572
prop: React.createElement('div', null, 'mouse', React.createElement('span', null, 'rat')),
573573
}),
574-
'<Mouse\n prop={\n <div>\n mouse\n <span>\n rat\n </span>\n </div>\n } />'
574+
'<Mouse\n prop={\n <div>\n mouse\n <span>\n rat\n </span>\n </div>\n }\n/>'
575575
);
576576
});
577577

@@ -586,7 +586,7 @@ describe('prettyFormat()', () => {
586586
],
587587
),
588588
}),
589-
'<Mouse\n prop={\n <div>\n mouse\n <span>\n rat\n </span>\n <span>\n cat\n </span>\n </div>\n } />'
589+
'<Mouse\n prop={\n <div>\n mouse\n <span>\n rat\n </span>\n <span>\n cat\n </span>\n </div>\n }\n/>'
590590
);
591591
});
592592

packages/pretty-format/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ function printPlugin(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDep
310310

311311
const opts = {
312312
edgeSpacing,
313+
min,
313314
spacing,
314315
};
315316
return plugin.print(val, boundPrint, boundIndent, opts, colors);

0 commit comments

Comments
 (0)