Skip to content

Commit 024c8d8

Browse files
authored
Add built-in component tests in vue/component-name-in-template-casing (#1737)
1 parent 09d7bed commit 024c8d8

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/lib/rules/component-name-in-template-casing.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ tester.run('component-name-in-template-casing', rule, {
6969
code: '<template><div><slot></slot></div></template>',
7070
options: ['PascalCase', { registeredComponentsOnly: false }]
7171
},
72+
{
73+
code: '<template><div><template v-if="foo">bar</template></div></template>',
74+
options: ['PascalCase', { registeredComponentsOnly: false }]
75+
},
7276
{
7377
code: '<template><h1>Title</h1></template>',
7478
options: ['PascalCase', { registeredComponentsOnly: false }]
@@ -151,6 +155,19 @@ tester.run('component-name-in-template-casing', rule, {
151155
{
152156
code: '<template><the-component><!--test</the-component></template>',
153157
options: ['PascalCase', { registeredComponentsOnly: false }]
158+
},
159+
160+
// built-in components (behave the same way as other components)
161+
{
162+
code: `
163+
<template>
164+
<component />
165+
<suspense />
166+
<teleport />
167+
<client-only />
168+
<keep-alive />
169+
</template>
170+
`
154171
}
155172
],
156173
invalid: [
@@ -768,6 +785,35 @@ tester.run('component-name-in-template-casing', rule, {
768785
'Component name "FooBar" is not kebab-case.',
769786
'Component name "FooBar_Baz-qux" is not kebab-case.'
770787
]
788+
},
789+
{
790+
// built-in components (behave the same way as other components)
791+
code: `
792+
<template>
793+
<component />
794+
<suspense />
795+
<teleport />
796+
<client-only />
797+
<keep-alive />
798+
</template>
799+
`,
800+
output: `
801+
<template>
802+
<Component />
803+
<Suspense />
804+
<Teleport />
805+
<ClientOnly />
806+
<KeepAlive />
807+
</template>
808+
`,
809+
options: ['PascalCase', { registeredComponentsOnly: false }],
810+
errors: [
811+
'Component name "component" is not PascalCase.',
812+
'Component name "suspense" is not PascalCase.',
813+
'Component name "teleport" is not PascalCase.',
814+
'Component name "client-only" is not PascalCase.',
815+
'Component name "keep-alive" is not PascalCase.'
816+
]
771817
}
772818
]
773819
})

0 commit comments

Comments
 (0)