Skip to content

Commit 799dfa6

Browse files
committed
failing tests describing how to handle non-element jsx nodes
1 parent e51c4cf commit 799dfa6

File tree

1 file changed

+106
-2
lines changed

1 file changed

+106
-2
lines changed

tests/lib/rules/jsx-one-element-per-line.js

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ ruleTester.run('jsx-max-elements-per-line', rule, {
5656
' <Foo></Foo>',
5757
'</App>'
5858
].join('\n')
59+
}, {
60+
code: [
61+
'<App>',
62+
' foo bar baz whatever ',
63+
'</App>'
64+
].join('\n')
5965
}, {
6066
code: [
6167
'<App>',
@@ -102,17 +108,115 @@ ruleTester.run('jsx-max-elements-per-line', rule, {
102108
}, {
103109
code: [
104110
'<div>',
105-
' <span />foo<input />',
111+
' <span />foo',
106112
'</div>'
107113
].join('\n'),
108114
output: [
109115
'<div>',
110-
' <span />foo',
116+
' <span />',
117+
'foo',
118+
'</div>'
119+
].join('\n'),
120+
errors: [{message: 'Literal `foo` must be placed on a new line'}],
121+
parserOptions: parserOptions
122+
}, {
123+
code: [
124+
'<div>',
125+
' <span />{"foo"}',
126+
'</div>'
127+
].join('\n'),
128+
output: [
129+
'<div>',
130+
' <span />',
131+
'{"foo"}',
132+
'</div>'
133+
].join('\n'),
134+
errors: [{message: 'Literal `{"foo"}` must be placed on a new line'}], // TODO: Replace `Literal` with proper term.
135+
parserOptions: parserOptions
136+
}, {
137+
code: [
138+
'<div>',
139+
' foo<input />',
140+
'</div>'
141+
].join('\n'),
142+
output: [
143+
'<div>',
144+
' foo',
111145
'<input />',
112146
'</div>'
113147
].join('\n'),
114148
errors: [{message: 'Opening tag for Element `input` must be placed on a new line'}],
115149
parserOptions: parserOptions
150+
}, {
151+
code: [
152+
'<div>',
153+
' {"foo"}<span />',
154+
'</div>'
155+
].join('\n'),
156+
output: [
157+
'<div>',
158+
' {"foo"}',
159+
'<span />',
160+
'</div>'
161+
].join('\n'),
162+
errors: [{message: 'Opening tag for Element `span` must be placed on a new line'}],
163+
parserOptions: parserOptions
164+
}, {
165+
code: [
166+
'<div>',
167+
' foo <input />',
168+
'</div>'
169+
].join('\n'),
170+
errors: [{message: 'Opening tag for Element `input` must be placed on a new line'}],
171+
parserOptions: parserOptions
172+
}, {
173+
code: [
174+
'<div>',
175+
' <span /> <input />',
176+
'</div>'
177+
].join('\n'),
178+
errors: [{message: 'Opening tag for Element `input` must be placed on a new line'}],
179+
parserOptions: parserOptions
180+
}, {
181+
code: [
182+
'<div>',
183+
' <input /> foo',
184+
'</div>'
185+
].join('\n'),
186+
errors: [{message: 'Literal ` foo` must be placed on a new line'}],
187+
parserOptions: parserOptions
188+
}, {
189+
code: [
190+
'<div>',
191+
' {"foo"} <input />',
192+
'</div>'
193+
].join('\n'),
194+
errors: [{message: 'Opening tag for Element `input` must be placed on a new line'}],
195+
parserOptions: parserOptions
196+
}, {
197+
code: [
198+
'<div>',
199+
' {"foo"} bar',
200+
'</div>'
201+
].join('\n'),
202+
errors: [{message: 'Literal `bar` must be placed on a new line'}],
203+
parserOptions: parserOptions
204+
}, {
205+
code: [
206+
'<div>',
207+
' foo {"bar"}',
208+
'</div>'
209+
].join('\n'),
210+
errors: [{message: 'Literal `{"bar"}` must be placed on a new line'}], // TODO: Replace `Literal` with proper term.
211+
parserOptions: parserOptions
212+
}, {
213+
code: [
214+
'<div>',
215+
' <input /> {"foo"}',
216+
'</div>'
217+
].join('\n'),
218+
errors: [{message: 'Literal `{"foo"}` must be placed on a new line'}], // TODO: Replace `Literal` with proper term.
219+
parserOptions: parserOptions
116220
}, {
117221
code: [
118222
'<App>',

0 commit comments

Comments
 (0)