+
+ This is Same name component!
+
+
+
diff --git a/packages/nuxt/test/scan-components.test.ts b/packages/nuxt/test/scan-components.test.ts
index 5a1a26b05f..0c4025f2a0 100644
--- a/packages/nuxt/test/scan-components.test.ts
+++ b/packages/nuxt/test/scan-components.test.ts
@@ -1,8 +1,8 @@
import { resolve } from 'node:path'
-import { expect, it, vi } from 'vitest'
+import { describe, expect, it, vi } from 'vitest'
import type { ComponentsDir } from 'nuxt/schema'
-import { scanComponents } from '../src/components/scan'
+import { resolveComponentName, scanComponents } from '../src/components/scan'
const fixtureDir = resolve(__dirname, 'fixture')
const rFixture = (...p: string[]) => resolve(fixtureDir, ...p)
@@ -192,6 +192,19 @@ const expectedComponents = [
preload: false,
priority: 1
},
+ {
+ chunkName: 'components/same-name-same',
+ export: 'default',
+ global: undefined,
+ island: undefined,
+ kebabName: 'same-name-same',
+ mode: 'all',
+ pascalName: 'SameNameSame',
+ prefetch: false,
+ preload: false,
+ priority: 1,
+ shortPath: 'components/same-name/same/Same.vue'
+ },
{
chunkName: 'components/some-glob',
export: 'default',
@@ -230,3 +243,25 @@ it('components:scanComponents', async () => {
}
expect(scannedComponents).deep.eq(expectedComponents)
})
+
+const tests: Array<[string, string[], string]> = [
+ ['WithClientOnlySetup', ['Client'], 'ClientWithClientOnlySetup'],
+ ['ItemHolderItem', ['Item', 'Holder', 'Item'], 'ItemHolderItem'],
+ ['Item', ['Item'], 'Item'],
+ ['Item', ['Item', 'Item'], 'Item'],
+ ['ItemTest', ['Item', 'Test'], 'ItemTest'],
+ ['ThingItemTest', ['Item', 'Thing'], 'ItemThingItemTest'],
+ ['Item', ['Thing', 'Item'], 'ThingItem'],
+ ['Item', ['Item', 'Holder', 'Item'], 'ItemHolderItem'],
+ ['ItemHolder', ['Item', 'Holder', 'Item'], 'ItemHolderItemHolder'],
+ ['ThingItemTest', ['Item', 'Thing', 'Foo'], 'ItemThingFooThingItemTest'],
+ ['ItemIn', ['Item', 'Holder', 'Item', 'In'], 'ItemHolderItemIn'],
+ ['Item', ['Item', 'Holder', 'Test'], 'ItemHolderTestItem'],
+ ['ItemHolderItem', ['Item', 'Holder', 'Item', 'Holder'], 'ItemHolderItemHolderItem']
+]
+
+describe('components:resolveComponentName', () => {
+ it.each(tests)('resolves %s with prefix parts %s and filename %s', (fileName, prefixParts: string[], result) => {
+ expect(resolveComponentName(fileName, prefixParts)).toBe(result)
+ })
+})