Skip to content

Commit

Permalink
test(core): add more cases for inferPagePath
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed Sep 11, 2024
1 parent 12dbc67 commit 7234a86
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/src/page/inferPagePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const inferPagePath = ({

// infer page route path from file path
// foo/bar.md -> /foo/bar.html
const pathInferred = ensureLeadingSlash(inferRoutePath(filePathRelative))
const pathInferred = inferRoutePath(ensureLeadingSlash(filePathRelative))

// resolve page locale path
const pathLocale = resolveLocalePath(app.siteData.locales, pathInferred)
Expand Down
28 changes: 28 additions & 0 deletions packages/core/tests/page/inferPagePath.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,55 @@ const appWithoutLocales = createBaseApp({
})

const TEST_CASES: [string, ReturnType<typeof inferPagePath>][] = [
[
'README.md',
{
pathInferred: '/',
pathLocale: '/',
},
],
[
'foo.md',
{
pathInferred: '/foo.html',
pathLocale: '/',
},
],
[
'en/README.md',
{
pathInferred: '/en/',
pathLocale: '/en/',
},
],
[
'en/foo.md',
{
pathInferred: '/en/foo.html',
pathLocale: '/en/',
},
],
[
'zh/README.md',
{
pathInferred: '/zh/',
pathLocale: '/zh/',
},
],
[
'zh/foo.md',
{
pathInferred: '/zh/foo.html',
pathLocale: '/zh/',
},
],
[
'中文/README.md',
{
pathInferred: '/中文/',
pathLocale: '/中文/',
},
],
[
'中文/foo.md',
{
Expand Down

0 comments on commit 7234a86

Please sign in to comment.