Skip to content

Commit 76fb2ab

Browse files
committed
test: page title should work fine
1 parent 015e6c1 commit 76fb2ab

File tree

1 file changed

+24
-2
lines changed
  • packages/@vuepress/core/lib/node/__tests__/prepare

1 file changed

+24
-2
lines changed

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ describe('permalink', () => {
8686
describe('markdown page', () => {
8787
test('should be able to pointing to a markdown file', async () => {
8888
const { relative, filePath } = getDocument('README.md')
89-
console.log('relative', relative)
9089
const markdown = getMarkdown()
9190
const page = await setupPage({ filePath, relative }, { markdown })
9291

@@ -116,6 +115,30 @@ describe('markdown page', () => {
116115
})
117116
})
118117

118+
describe('title', () => {
119+
test('should be able to set title', async () => {
120+
const title = 'VuePress'
121+
const page = await setupPage({ path: '/', title })
122+
expect(page.title).toBe(title)
123+
})
124+
125+
test('should set title from frontmatter', async () => {
126+
const title = 'VuePress Alpha' // from fixture
127+
const { relative, filePath } = getDocument('alpha.md')
128+
const markdown = getMarkdown()
129+
const page = await setupPage({ filePath, relative }, { markdown })
130+
expect(page.title).toBe(title)
131+
})
132+
133+
test('should use first header in markdown to set title ', async () => {
134+
const title = 'Home' // from fixture
135+
const { relative, filePath } = getDocument('README.md')
136+
const markdown = getMarkdown()
137+
const page = await setupPage({ filePath, relative }, { markdown })
138+
expect(page.title).toBe(title)
139+
})
140+
})
141+
119142
describe('enhancer', () => {
120143
test('should loop over sync enhancers', async () => {
121144
const page = await setupPage({ path: '/' })
@@ -172,7 +195,6 @@ describe('enhancer', () => {
172195
})
173196

174197
// TODO permalink - driven by global pattern
175-
// TODO Title
176198
// TODO I18n
177199
// TODO Meta
178200
// TODO Add a page with explicit content

0 commit comments

Comments
 (0)