Skip to content

Commit 0922c56

Browse files
committed
Add some more test cases
1 parent a6e39d0 commit 0922c56

File tree

2 files changed

+105
-1
lines changed

2 files changed

+105
-1
lines changed

lib/rules/jsx-child-element-spacing.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
// TODO(pfhayes): Just a stub for now to get tests working
43
module.exports = {
54
meta: {
65
docs: {},

tests/lib/rules/jsx-child-element-spacing.js

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,26 @@ const ERROR_MESSAGE = [{message: 'Ambiguous spacing between child elements.'}];
1414
const ruleTester = new RuleTester({parserOptions});
1515
ruleTester.run('jsx-child-element-spacing', rule, {
1616
valid: [{
17+
code: `
18+
<App>
19+
foo
20+
</App>
21+
`
22+
}, {
23+
code: `
24+
<App>
25+
<a>bar</a>
26+
</App>
27+
`
28+
}, {
29+
code: `
30+
<App>
31+
<a>
32+
<b>nested</b>
33+
</a>
34+
</App>
35+
`
36+
}, {
1737
code: `
1838
<App>
1939
foo
@@ -43,6 +63,22 @@ ruleTester.run('jsx-child-element-spacing', rule, {
4363
baz
4464
</App>
4565
`
66+
}, {
67+
code: `
68+
<App>
69+
foo
70+
{' '}<a>bar</a>{' '}
71+
baz
72+
</App>
73+
`
74+
}, {
75+
code: `
76+
<App>
77+
foo{' '}
78+
<a>bar</a>
79+
{' '}baz
80+
</App>
81+
`
4682
}, {
4783
code: `
4884
<App>
@@ -51,6 +87,40 @@ ruleTester.run('jsx-child-element-spacing', rule, {
5187
*/}baz
5288
</App>
5389
`
90+
}, {
91+
code: `
92+
<App>
93+
Please take a look at <a href="https://js.org">this link</a>.
94+
</App>
95+
`
96+
}, {
97+
code: `
98+
<App>
99+
Please take a look at
100+
{' '}
101+
<a href="https://js.org">this link</a>.
102+
</App>
103+
`
104+
}, {
105+
code: `
106+
<App>
107+
<p>A</p>
108+
<p>B</p>
109+
</App>
110+
`
111+
}, {
112+
code: `
113+
<App>
114+
<p>A</p><p>B</p>
115+
</App>
116+
`
117+
}, {
118+
code: `
119+
<App>
120+
A
121+
B
122+
</App>
123+
`
54124
}],
55125

56126
invalid: [{
@@ -69,5 +139,40 @@ ruleTester.run('jsx-child-element-spacing', rule, {
69139
</App>
70140
`,
71141
errors: ERROR_MESSAGE
142+
}, {
143+
code: `
144+
<App>
145+
{' '}<a>bar</a>
146+
baz
147+
</App>
148+
`,
149+
errors: ERROR_MESSAGE
150+
}, {
151+
code: `
152+
<App>
153+
Please take a look at
154+
<a href="https://js.org">this link</a>.
155+
</App>
156+
`,
157+
errors: ERROR_MESSAGE
158+
}, {
159+
code: `
160+
<App>
161+
Here is
162+
<a href="https://js.org">a link</a> and here is
163+
<a href="https://js.org">another</a>
164+
</App>
165+
`,
166+
errors: ERROR_MESSAGE
167+
}, {
168+
code: `
169+
<App>
170+
<a>
171+
<b>nested1</b>
172+
<b>nested2</b>
173+
</a>
174+
</App>
175+
`,
176+
errors: ERROR_MESSAGE
72177
}]
73178
});

0 commit comments

Comments
 (0)