@@ -47,6 +47,40 @@ var RETURN_NO_PAREN = '\
47
47
}\
48
48
});' ;
49
49
50
+ var DECLARATION_TERNARY_SINGLE_LINE = 'var hello = foo ? <p>Hello</p> : <p>Hi</p>;' ;
51
+
52
+ var DECLARATION_TERNARY_PAREN = '\
53
+ var hello = foo ? (<div>\n\
54
+ <p>Hello</p>\n\
55
+ </div>) : (<div>\n\
56
+ <p>Hi</p>\n\
57
+ </div>);' ;
58
+
59
+ var DECLARATION_TERNARY_NO_PAREN = '\
60
+ var hello = foo ? <div>\n\
61
+ <p>Hello</p>\n\
62
+ </div> : <div>\n\
63
+ <p>Hi</p>\n\
64
+ </div>;' ;
65
+
66
+ var ASSIGNMENT_TERNARY_SINGLE_LINE = 'var hello; hello = foo ? <p>Hello</p> : <p>Hi</p>;' ;
67
+
68
+ var ASSIGNMENT_TERNARY_PAREN = '\
69
+ var hello;\n\
70
+ hello = foo ? (<div>\n\
71
+ <p>Hello</p>\n\
72
+ </div>) : (<div>\n\
73
+ <p>Hi</p>\n\
74
+ </div>);' ;
75
+
76
+ var ASSIGNMENT_TERNARY_NO_PAREN = '\
77
+ var hello;\n\
78
+ hello = foo ? <div>\n\
79
+ <p>Hello</p>\n\
80
+ </div> : <div>\n\
81
+ <p>Hi</p>\n\
82
+ </div>;' ;
83
+
50
84
var DECLARATION_SINGLE_LINE = 'var hello = <p>Hello</p>;' ;
51
85
52
86
var DECLARATION_PAREN = '\
@@ -91,6 +125,26 @@ ruleTester.run('jsx-wrap-multilines', rule, {
91
125
code : RETURN_NO_PAREN ,
92
126
options : [ { return : false } ] ,
93
127
parserOptions : parserOptions
128
+ } , {
129
+ code : DECLARATION_TERNARY_SINGLE_LINE ,
130
+ parserOptions : parserOptions
131
+ } , {
132
+ code : DECLARATION_TERNARY_PAREN ,
133
+ parserOptions : parserOptions
134
+ } , {
135
+ code : DECLARATION_TERNARY_NO_PAREN ,
136
+ options : [ { declaration : false } ] ,
137
+ parserOptions : parserOptions
138
+ } , {
139
+ code : ASSIGNMENT_TERNARY_SINGLE_LINE ,
140
+ parserOptions : parserOptions
141
+ } , {
142
+ code : ASSIGNMENT_TERNARY_PAREN ,
143
+ parserOptions : parserOptions
144
+ } , {
145
+ code : ASSIGNMENT_TERNARY_NO_PAREN ,
146
+ options : [ { assignment : false } ] ,
147
+ parserOptions : parserOptions
94
148
} , {
95
149
code : DECLARATION_SINGLE_LINE ,
96
150
parserOptions : parserOptions
@@ -127,6 +181,22 @@ ruleTester.run('jsx-wrap-multilines', rule, {
127
181
parserOptions : parserOptions ,
128
182
options : [ { return : true } ] ,
129
183
errors : [ { message : 'Missing parentheses around multilines JSX' } ]
184
+ } , {
185
+ code : DECLARATION_TERNARY_NO_PAREN ,
186
+ output : DECLARATION_TERNARY_PAREN ,
187
+ parserOptions : parserOptions ,
188
+ errors : [
189
+ { message : 'Missing parentheses around multilines JSX' } ,
190
+ { message : 'Missing parentheses around multilines JSX' }
191
+ ]
192
+ } , {
193
+ code : ASSIGNMENT_TERNARY_NO_PAREN ,
194
+ output : ASSIGNMENT_TERNARY_PAREN ,
195
+ parserOptions : parserOptions ,
196
+ errors : [
197
+ { message : 'Missing parentheses around multilines JSX' } ,
198
+ { message : 'Missing parentheses around multilines JSX' }
199
+ ]
130
200
} , {
131
201
code : DECLARATION_NO_PAREN ,
132
202
output : DECLARATION_PAREN ,
0 commit comments