Skip to content

Commit

Permalink
test: update test suite for pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
danpacho committed Dec 29, 2024
1 parent 521dc23 commit e55d9c5
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,30 @@ describe('StaticParamBuilderPlugin', () => {
it('should inject static params to the content', async () => {
const plugin = new StaticParamBuilderPlugin()
plugin.injectDynamicConfig({
paramShape: '/[...posts]',
paramShape: '/posts/$page/[...posts]',
maxPage: 2,
})

const { buildFileNames, buildFiles } = await Tester.pipe({
const { buildFiles } = await Tester.pipe({
plugin: {
'walk:tree': plugin,
},
})

const metaList = buildFiles.contents.map((e) => e.meta!.params)
const expectedPostParams = buildFileNames.contents.map((e) => {
const param = e.split('.').slice(0, -1)[0]
return {
posts: param,
}
})
expect(metaList).toEqual(expectedPostParams)
expect(metaList).toEqual([
{
posts: 'posts/1/img',
},
{
posts: 'posts/1/link',
},
{
posts: 'posts/2/markdown',
},
{
posts: 'posts/2/nested/nested/nested',
},
])
})
})

0 comments on commit e55d9c5

Please sign in to comment.