Skip to content

Commit 7234a86

Browse files
committed
test(core): add more cases for inferPagePath
1 parent 12dbc67 commit 7234a86

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

packages/core/src/page/inferPagePath.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const inferPagePath = ({
2727

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

3232
// resolve page locale path
3333
const pathLocale = resolveLocalePath(app.siteData.locales, pathInferred)

packages/core/tests/page/inferPagePath.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,55 @@ const appWithoutLocales = createBaseApp({
2121
})
2222

2323
const TEST_CASES: [string, ReturnType<typeof inferPagePath>][] = [
24+
[
25+
'README.md',
26+
{
27+
pathInferred: '/',
28+
pathLocale: '/',
29+
},
30+
],
2431
[
2532
'foo.md',
2633
{
2734
pathInferred: '/foo.html',
2835
pathLocale: '/',
2936
},
3037
],
38+
[
39+
'en/README.md',
40+
{
41+
pathInferred: '/en/',
42+
pathLocale: '/en/',
43+
},
44+
],
3145
[
3246
'en/foo.md',
3347
{
3448
pathInferred: '/en/foo.html',
3549
pathLocale: '/en/',
3650
},
3751
],
52+
[
53+
'zh/README.md',
54+
{
55+
pathInferred: '/zh/',
56+
pathLocale: '/zh/',
57+
},
58+
],
3859
[
3960
'zh/foo.md',
4061
{
4162
pathInferred: '/zh/foo.html',
4263
pathLocale: '/zh/',
4364
},
4465
],
66+
[
67+
'中文/README.md',
68+
{
69+
pathInferred: '/中文/',
70+
pathLocale: '/中文/',
71+
},
72+
],
4573
[
4674
'中文/foo.md',
4775
{

0 commit comments

Comments
 (0)