Skip to content

Commit 5fd9316

Browse files
committed
test: should be able to set permalink from global pattern
1 parent 7a2d1bf commit 5fd9316

File tree

1 file changed

+15
-4
lines changed
  • packages/@vuepress/core/lib/node/__tests__/prepare

1 file changed

+15
-4
lines changed

packages/@vuepress/core/lib/node/__tests__/prepare/Page.spec.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,21 @@ describe('permalink', () => {
8181
expect(page.path).toBe('/permalink/')
8282
expect(page.regularPath).toBe('/')
8383
})
84+
85+
test('should be able to set permalink from global pattern', async () => {
86+
const permalinkPattern = '/:year/:month/:day/:slug'
87+
const { relative, filePath } = getDocument('2020-01-01-date.md')
88+
const markdown = getMarkdown()
89+
const page = await setupPage({ filePath, relative, permalinkPattern }, { markdown })
90+
expect(page.path).toBe('/2020/01/01/date/')
91+
expect(page.regularPath).toBe('/2020-01-01-date.html')
92+
93+
const pageWithLocalePath = await setupPage(
94+
{ filePath, relative, permalinkPattern },
95+
{ computed: { setPage () {}, $localePath: '/zh/' }, markdown }
96+
)
97+
expect(pageWithLocalePath.path).toBe('/zh/2020/01/01/date/')
98+
})
8499
})
85100

86101
describe('markdown page', () => {
@@ -282,7 +297,3 @@ describe('public api', () => {
282297
})
283298
})
284299

285-
// TODO permalink - driven by global pattern
286-
// TODO I18n
287-
// TODO SFC
288-

0 commit comments

Comments
 (0)