Skip to content

Commit aa6e06d

Browse files
committed
test(core): fix test cases
1 parent b0fc856 commit aa6e06d

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

packages/@vuepress/core/__tests__/page/createPage.spec.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,19 @@ describe('core > page > createPage', () => {
5050
expect(page.contentRendered).toBe('')
5151
expect(page.date).toBe('0000-00-00')
5252
expect(page.deps).toEqual([])
53-
expect(page.sfcBlocks).toEqual([])
53+
expect(page.sfcBlocks).toEqual({
54+
template: {
55+
type: 'template',
56+
content: '<template></template>',
57+
contentStripped: '',
58+
tagClose: '</template>',
59+
tagOpen: '<template>',
60+
},
61+
script: null,
62+
scriptSetup: null,
63+
styles: [],
64+
customBlocks: [],
65+
})
5466
expect(page.links).toEqual([])
5567
expect(page.pathInferred).toBeNull()
5668
expect(page.pathLocale).toBe('/')

packages/@vuepress/core/__tests__/page/renderPageContent.spec.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ describe('core > page > renderPageContent', () => {
1313
it('should render page content correctly', async () => {
1414
const resolved = await renderPageContent({
1515
app,
16-
content: 'foobar',
16+
content: `\
17+
foobar
18+
<script setup lang="ts">
19+
const msg = 'msg'
20+
</script>
21+
`,
1722
filePath: app.dir.source('foo.md'),
1823
filePathRelative: 'foo.md',
1924
options: {},
@@ -26,7 +31,25 @@ describe('core > page > renderPageContent', () => {
2631
frontmatter: {},
2732
headers: [],
2833
links: [],
29-
sfcBlocks: [],
34+
sfcBlocks: {
35+
template: {
36+
type: 'template',
37+
content: '<template><p>foobar</p>\n</template>',
38+
contentStripped: '<p>foobar</p>\n',
39+
tagClose: '</template>',
40+
tagOpen: '<template>',
41+
},
42+
script: null,
43+
scriptSetup: {
44+
type: 'script',
45+
content: `<script setup lang="ts">\nconst msg = 'msg'\n</script>`,
46+
contentStripped: `\nconst msg = 'msg'\n`,
47+
tagClose: '</script>',
48+
tagOpen: '<script setup lang="ts">',
49+
},
50+
styles: [],
51+
customBlocks: [],
52+
},
3053
title: '',
3154
})
3255
})

0 commit comments

Comments
 (0)