feat(content-blog): allow sorting posts in ascending order (#5787)

This commit is contained in:
Devtato 2021-11-09 18:25:43 +01:00 committed by GitHub
parent 8fba542d26
commit 1c024470e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 0 deletions

View file

@ -394,4 +394,15 @@ describe('loadBlog', () => {
truncated: false,
});
});
test('test ascending sort direction of blog post', async () => {
const siteDir = path.join(__dirname, '__fixtures__', 'website');
const normalOrder = await getBlogPosts(siteDir);
const reversedOrder = await getBlogPosts(siteDir, {
sortPosts: 'ascending',
});
expect(normalOrder.reverse().map((x) => x.metadata.date)).toEqual(
reversedOrder.map((x) => x.metadata.date),
);
});
});