test: update test and make index replacement case-insensitive

This commit is contained in:
Daniel Roe 2023-10-16 13:41:06 +01:00
parent 7db327cf9b
commit db9cc66a3e
2 changed files with 6 additions and 1 deletions

View File

@ -6,7 +6,7 @@ export function getNameFromPath (path: string, relativeTo?: string) {
const relativePath = relativeTo
? normalize(path).replace(withTrailingSlash(normalize(relativeTo)), '')
: basename(path)
return kebabCase(relativePath.replace(/\/index\.\w+$/, '').replace(/[\\/]+/g, '-').replace(extname(relativePath), '')).replace(/["']/g, '')
return kebabCase(relativePath.replace(/\/index\.\w+$/i, '').replace(/[\\/]+/g, '-').replace(extname(relativePath), '')).replace(/["']/g, '')
}
export function hasSuffix (path: string, suffix: string) {

View File

@ -185,6 +185,7 @@ describe('resolveApp', () => {
'layouts/default.vue',
'layouts/some/layout.vue',
'layouts/SomeOther.vue',
'layouts/SomeOther/Thing/Index.vue',
'layouts/some.vue',
'layouts/SomeOther/layout.ts'
])
@ -210,6 +211,10 @@ describe('resolveApp', () => {
"file": "<rootDir>/layouts/SomeOther/layout.ts",
"name": "some-other-layout",
},
"some-other-thing": {
"file": "<rootDir>/layouts/SomeOther/Thing/Index.vue",
"name": "some-other-thing",
},
}
`)
})