From 7234a86993861f0de3a71cb3132020df91e4c3f2 Mon Sep 17 00:00:00 2001 From: meteorlxy Date: Wed, 11 Sep 2024 20:32:11 +0800 Subject: [PATCH] test(core): add more cases for inferPagePath --- packages/core/src/page/inferPagePath.ts | 2 +- .../core/tests/page/inferPagePath.spec.ts | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/core/src/page/inferPagePath.ts b/packages/core/src/page/inferPagePath.ts index 098e79985a..8d082ea93c 100644 --- a/packages/core/src/page/inferPagePath.ts +++ b/packages/core/src/page/inferPagePath.ts @@ -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) diff --git a/packages/core/tests/page/inferPagePath.spec.ts b/packages/core/tests/page/inferPagePath.spec.ts index f65aced2ad..faac1b12b3 100644 --- a/packages/core/tests/page/inferPagePath.spec.ts +++ b/packages/core/tests/page/inferPagePath.spec.ts @@ -21,6 +21,13 @@ const appWithoutLocales = createBaseApp({ }) const TEST_CASES: [string, ReturnType][] = [ + [ + 'README.md', + { + pathInferred: '/', + pathLocale: '/', + }, + ], [ 'foo.md', { @@ -28,6 +35,13 @@ const TEST_CASES: [string, ReturnType][] = [ pathLocale: '/', }, ], + [ + 'en/README.md', + { + pathInferred: '/en/', + pathLocale: '/en/', + }, + ], [ 'en/foo.md', { @@ -35,6 +49,13 @@ const TEST_CASES: [string, ReturnType][] = [ pathLocale: '/en/', }, ], + [ + 'zh/README.md', + { + pathInferred: '/zh/', + pathLocale: '/zh/', + }, + ], [ 'zh/foo.md', { @@ -42,6 +63,13 @@ const TEST_CASES: [string, ReturnType][] = [ pathLocale: '/zh/', }, ], + [ + '中文/README.md', + { + pathInferred: '/中文/', + pathLocale: '/中文/', + }, + ], [ '中文/foo.md', {