Skip to content

Commit d00e8c0

Browse files
authored
test(html-self-closing): make tests more strict (#2840)
1 parent 09380b5 commit d00e8c0

File tree

1 file changed

+98
-15
lines changed

1 file changed

+98
-15
lines changed

tests/lib/rules/html-self-closing.js

Lines changed: 98 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,68 @@ tester.run('html-self-closing', rule, {
9090
{
9191
code: '<template><div></div></template>',
9292
output: '<template><div/></template>',
93-
errors: ['Require self-closing on HTML elements (<div>).']
93+
errors: [
94+
{
95+
message: 'Require self-closing on HTML elements (<div>).',
96+
line: 1,
97+
column: 16,
98+
endLine: 1,
99+
endColumn: 22
100+
}
101+
]
94102
},
95103
{
96104
code: '<template><img/></template>',
97105
output: '<template><img></template>',
98-
errors: ['Disallow self-closing on HTML void elements (<img/>).']
106+
errors: [
107+
{
108+
message: 'Disallow self-closing on HTML void elements (<img/>).',
109+
line: 1,
110+
column: 15,
111+
endLine: 1,
112+
endColumn: 17
113+
}
114+
]
99115
},
100116
{
101117
code: '<template><x-test></x-test></template>',
102118
output: '<template><x-test/></template>',
103-
errors: ['Require self-closing on Vue.js custom components (<x-test>).']
119+
errors: [
120+
{
121+
message:
122+
'Require self-closing on Vue.js custom components (<x-test>).',
123+
line: 1,
124+
column: 19,
125+
endLine: 1,
126+
endColumn: 28
127+
}
128+
]
104129
},
105130
{
106131
code: '<template><svg><path></path></svg></template>',
107132
output: '<template><svg><path/></svg></template>',
108-
errors: ['Require self-closing on SVG elements (<path>).']
133+
errors: [
134+
{
135+
message: 'Require self-closing on SVG elements (<path>).',
136+
line: 1,
137+
column: 22,
138+
endLine: 1,
139+
endColumn: 29
140+
}
141+
]
109142
},
110143
{
111144
code: '<template><math><mspace></mspace></math></template>',
112145
output: '<template><math><mspace/></math></template>',
113-
errors: ['Require self-closing on MathML elements (<mspace>).']
146+
errors: [
147+
{
148+
message: 'Require self-closing on MathML elements (<mspace>).',
149+
line: 1,
150+
column: 25,
151+
endLine: 1,
152+
endColumn: 34
153+
}
154+
]
114155
},
115156

116157
// others
@@ -130,7 +171,13 @@ tester.run('html-self-closing', rule, {
130171
</template>`,
131172
options: [anyWith({ html: { normal: 'always' } })],
132173
errors: [
133-
{ message: 'Require self-closing on HTML elements (<div>).', line: 2 }
174+
{
175+
message: 'Require self-closing on HTML elements (<div>).',
176+
line: 2,
177+
column: 8,
178+
endLine: 2,
179+
endColumn: 14
180+
}
134181
]
135182
},
136183
{
@@ -149,7 +196,13 @@ tester.run('html-self-closing', rule, {
149196
</template>`,
150197
options: [anyWith({ html: { normal: 'never' } })],
151198
errors: [
152-
{ message: 'Disallow self-closing on HTML elements (<div/>).', line: 3 }
199+
{
200+
message: 'Disallow self-closing on HTML elements (<div/>).',
201+
line: 3,
202+
column: 7,
203+
endLine: 3,
204+
endColumn: 9
205+
}
153206
]
154207
},
155208
{
@@ -170,7 +223,10 @@ tester.run('html-self-closing', rule, {
170223
errors: [
171224
{
172225
message: 'Require self-closing on HTML void elements (<img>).',
173-
line: 4
226+
line: 4,
227+
column: 3,
228+
endLine: 4,
229+
endColumn: 8
174230
}
175231
]
176232
},
@@ -192,7 +248,10 @@ tester.run('html-self-closing', rule, {
192248
errors: [
193249
{
194250
message: 'Disallow self-closing on HTML void elements (<img/>).',
195-
line: 5
251+
line: 5,
252+
column: 7,
253+
endLine: 5,
254+
endColumn: 9
196255
}
197256
]
198257
},
@@ -215,7 +274,10 @@ tester.run('html-self-closing', rule, {
215274
{
216275
message:
217276
'Require self-closing on Vue.js custom components (<x-test>).',
218-
line: 6
277+
line: 6,
278+
column: 11,
279+
endLine: 6,
280+
endColumn: 20
219281
}
220282
]
221283
},
@@ -238,7 +300,10 @@ tester.run('html-self-closing', rule, {
238300
{
239301
message:
240302
'Disallow self-closing on Vue.js custom components (<x-test/>).',
241-
line: 7
303+
line: 7,
304+
column: 10,
305+
endLine: 7,
306+
endColumn: 12
242307
}
243308
]
244309
},
@@ -258,7 +323,13 @@ tester.run('html-self-closing', rule, {
258323
</template>`,
259324
options: [anyWith({ svg: 'always' })],
260325
errors: [
261-
{ message: 'Require self-closing on SVG elements (<path>).', line: 8 }
326+
{
327+
message: 'Require self-closing on SVG elements (<path>).',
328+
line: 8,
329+
column: 14,
330+
endLine: 8,
331+
endColumn: 21
332+
}
262333
]
263334
},
264335
{
@@ -277,7 +348,13 @@ tester.run('html-self-closing', rule, {
277348
</template>`,
278349
options: [anyWith({ svg: 'never' })],
279350
errors: [
280-
{ message: 'Disallow self-closing on SVG elements (<path/>).', line: 9 }
351+
{
352+
message: 'Disallow self-closing on SVG elements (<path/>).',
353+
line: 9,
354+
column: 13,
355+
endLine: 9,
356+
endColumn: 15
357+
}
281358
]
282359
},
283360
{
@@ -298,7 +375,10 @@ tester.run('html-self-closing', rule, {
298375
errors: [
299376
{
300377
message: 'Require self-closing on MathML elements (<mspace>).',
301-
line: 10
378+
line: 10,
379+
column: 17,
380+
endLine: 10,
381+
endColumn: 26
302382
}
303383
]
304384
},
@@ -320,7 +400,10 @@ tester.run('html-self-closing', rule, {
320400
errors: [
321401
{
322402
message: 'Disallow self-closing on MathML elements (<mspace/>).',
323-
line: 11
403+
line: 11,
404+
column: 16,
405+
endLine: 11,
406+
endColumn: 18
324407
}
325408
]
326409
}

0 commit comments

Comments
 (0)