Skip to content

Commit a05c589

Browse files
committed
[jsx-wrap-multilines] Return tests
1 parent cea8305 commit a05c589

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

tests/lib/rules/jsx-wrap-multilines.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,43 @@ const RETURN_NO_PAREN = `
5151
}
5252
});
5353
`;
54+
const DECLARATION_TERNARY_SINGLE_LINE = 'var hello = foo ? <p>Hello</p> : <p>Hi</p>;';
55+
56+
const DECLARATION_TERNARY_PAREN = `
57+
var hello = foo ? (<div>
58+
<p>Hello</p>
59+
</div>) : (<div>
60+
<p>Hi</p>
61+
</div>);
62+
`;
63+
64+
const DECLARATION_TERNARY_NO_PAREN = `
65+
var hello = foo ? <div>
66+
<p>Hello</p>
67+
</div> : <div>
68+
<p>Hi</p>
69+
</div>;
70+
`;
71+
72+
const ASSIGNMENT_TERNARY_SINGLE_LINE = 'var hello; hello = foo ? <p>Hello</p> : <p>Hi</p>;';
73+
74+
const ASSIGNMENT_TERNARY_PAREN = `
75+
var hello;
76+
hello = foo ? (<div>
77+
<p>Hello</p>
78+
</div>) : (<div>
79+
<p>Hi</p>
80+
</div>);
81+
`;
82+
83+
const ASSIGNMENT_TERNARY_NO_PAREN = `
84+
var hello;
85+
hello = foo ? <div>
86+
<p>Hello</p>
87+
</div> : <div>
88+
<p>Hi</p>
89+
</div>;
90+
`;
5491

5592
const DECLARATION_SINGLE_LINE = 'var hello = <p>Hello</p>;';
5693

@@ -173,6 +210,20 @@ ruleTester.run('jsx-wrap-multilines', rule, {
173210
}, {
174211
code: RETURN_NO_PAREN,
175212
options: [{return: false}]
213+
}, {
214+
code: DECLARATION_TERNARY_SINGLE_LINE
215+
}, {
216+
code: DECLARATION_TERNARY_PAREN
217+
}, {
218+
code: DECLARATION_TERNARY_NO_PAREN,
219+
options: [{declaration: false}]
220+
}, {
221+
code: ASSIGNMENT_TERNARY_SINGLE_LINE
222+
}, {
223+
code: ASSIGNMENT_TERNARY_PAREN
224+
}, {
225+
code: ASSIGNMENT_TERNARY_NO_PAREN,
226+
options: [{assignment: false}]
176227
}, {
177228
code: DECLARATION_SINGLE_LINE
178229
}, {

0 commit comments

Comments
 (0)