Skip to content

Commit f08411e

Browse files
committed
test(formatter): Add tests for #16179 and #16180 (#16231)
Closes #16179 Bug itself was already fixed by #16224
1 parent 03f5729 commit f08411e

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

crates/oxc_formatter/tests/fixtures/js/jsx/ternary-with-comment.jsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,29 @@
1111
<Image {...props} /> // eslint-disable-line
1212
)}
1313
</>
14+
15+
// https://github.com/oxc-project/oxc/issues/16180
16+
{
17+
const x = (
18+
<>
19+
{xxxxxxxxxxxxxx ? (
20+
<div /> /** xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */
21+
) : (
22+
<div />
23+
)}
24+
</>
25+
);
26+
}
27+
28+
// https://github.com/oxc-project/oxc/issues/16179
29+
{
30+
const x = (
31+
<>
32+
{xxxxxxxxxxxx ? null /** xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */ : xxxxxxx ? (
33+
<div />
34+
) : (
35+
<div />
36+
)}
37+
</>
38+
);
39+
}

crates/oxc_formatter/tests/fixtures/js/jsx/ternary-with-comment.jsx.snap

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@ source: crates/oxc_formatter/tests/fixtures/mod.rs
1616
)}
1717
</>
1818

19+
// https://github.com/oxc-project/oxc/issues/16180
20+
{
21+
const x = (
22+
<>
23+
{xxxxxxxxxxxxxx ? (
24+
<div /> /** xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */
25+
) : (
26+
<div />
27+
)}
28+
</>
29+
);
30+
}
31+
32+
// https://github.com/oxc-project/oxc/issues/16179
33+
{
34+
const x = (
35+
<>
36+
{xxxxxxxxxxxx ? null /** xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */ : xxxxxxx ? (
37+
<div />
38+
) : (
39+
<div />
40+
)}
41+
</>
42+
);
43+
}
44+
1945
==================== Output ====================
2046
------------------
2147
{ printWidth: 80 }
@@ -36,6 +62,32 @@ source: crates/oxc_formatter/tests/fixtures/mod.rs
3662
)}
3763
</>;
3864

65+
// https://github.com/oxc-project/oxc/issues/16180
66+
{
67+
const x = (
68+
<>
69+
{xxxxxxxxxxxxxx ? (
70+
<div /> /** xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */
71+
) : (
72+
<div />
73+
)}
74+
</>
75+
);
76+
}
77+
78+
// https://github.com/oxc-project/oxc/issues/16179
79+
{
80+
const x = (
81+
<>
82+
{xxxxxxxxxxxx ? null /** xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */ : xxxxxxx ? (
83+
<div />
84+
) : (
85+
<div />
86+
)}
87+
</>
88+
);
89+
}
90+
3991
-------------------
4092
{ printWidth: 100 }
4193
-------------------
@@ -55,4 +107,30 @@ source: crates/oxc_formatter/tests/fixtures/mod.rs
55107
)}
56108
</>;
57109

110+
// https://github.com/oxc-project/oxc/issues/16180
111+
{
112+
const x = (
113+
<>
114+
{xxxxxxxxxxxxxx ? (
115+
<div /> /** xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */
116+
) : (
117+
<div />
118+
)}
119+
</>
120+
);
121+
}
122+
123+
// https://github.com/oxc-project/oxc/issues/16179
124+
{
125+
const x = (
126+
<>
127+
{xxxxxxxxxxxx ? null /** xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */ : xxxxxxx ? (
128+
<div />
129+
) : (
130+
<div />
131+
)}
132+
</>
133+
);
134+
}
135+
58136
===================== End =====================

0 commit comments

Comments
 (0)