Skip to content

Commit b4141d8

Browse files
Andreas Opferkuchljharb
Andreas Opferkuch
authored andcommitted
[Tests] Added tests for jsx-curly-spacing that deal with comments in children.
See also: #648 (comment)
1 parent c996740 commit b4141d8

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

tests/lib/rules/jsx-curly-spacing.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,6 +2148,40 @@ ruleTester.run('jsx-curly-spacing', rule, {
21482148
}, {
21492149
message: 'A space is required before \'}\''
21502150
}]
2151+
}, {
2152+
code: [
2153+
'<App>',
2154+
'{ /* comment */ }',
2155+
'</App>;'
2156+
].join('\n'),
2157+
output: [
2158+
'<App>',
2159+
'{/* comment */}',
2160+
'</App>;'
2161+
].join('\n'),
2162+
options: [{when: 'never', children: true}],
2163+
errors: [{
2164+
message: 'There should be no space after \'{\''
2165+
}, {
2166+
message: 'There should be no space before \'}\''
2167+
}]
2168+
}, {
2169+
code: [
2170+
'<App>',
2171+
'{/* comment */}',
2172+
'</App>;'
2173+
].join('\n'),
2174+
output: [
2175+
'<App>',
2176+
'{ /* comment */ }',
2177+
'</App>;'
2178+
].join('\n'),
2179+
options: [{when: 'always', children: true}],
2180+
errors: [{
2181+
message: 'A space is required after \'{\''
2182+
}, {
2183+
message: 'A space is required before \'}\''
2184+
}]
21512185
}, {
21522186
code: [
21532187
'<App>',
@@ -2180,5 +2214,47 @@ ruleTester.run('jsx-curly-spacing', rule, {
21802214
errors: [{
21812215
message: 'There should be no newline after \'{\''
21822216
}]
2217+
}, {
2218+
code: [
2219+
'<App>{ /* comment */',
2220+
'bar',
2221+
'} {',
2222+
'baz',
2223+
'/* comment */ }</App>;'
2224+
].join('\n'),
2225+
output: [
2226+
'<App>{/* comment */',
2227+
'bar',
2228+
'} {',
2229+
'baz',
2230+
'/* comment */}</App>;'
2231+
].join('\n'),
2232+
options: [{when: 'never', children: true}],
2233+
errors: [{
2234+
message: 'There should be no space after \'{\''
2235+
}, {
2236+
message: 'There should be no space before \'}\''
2237+
}]
2238+
}, {
2239+
code: [
2240+
'<App>{/* comment */',
2241+
'bar',
2242+
'} {',
2243+
'baz',
2244+
'/* comment */}</App>;'
2245+
].join('\n'),
2246+
output: [
2247+
'<App>{ /* comment */',
2248+
'bar',
2249+
'} {',
2250+
'baz',
2251+
'/* comment */ }</App>;'
2252+
].join('\n'),
2253+
options: [{when: 'always', children: true}],
2254+
errors: [{
2255+
message: 'A space is required after \'{\''
2256+
}, {
2257+
message: 'A space is required before \'}\''
2258+
}]
21832259
}]
21842260
});

0 commit comments

Comments
 (0)