From f89ffb118c3b4a578aa2af30e2e9e0955d80e66b Mon Sep 17 00:00:00 2001 From: D-Sketon <2055272094@qq.com> Date: Wed, 7 Feb 2024 20:54:25 +0800 Subject: [PATCH] fix coverage --- test/scripts/filters/post_permalink.ts | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test/scripts/filters/post_permalink.ts b/test/scripts/filters/post_permalink.ts index 6012b5ad58..dd530ab090 100644 --- a/test/scripts/filters/post_permalink.ts +++ b/test/scripts/filters/post_permalink.ts @@ -172,4 +172,52 @@ describe('post_permalink', () => { await Promise.all(posts.map(post => Post.removeById(post._id))); }); + + it('permalink - should end with / or .html - 1', async () => { + hexo.config.post_asset_folder = true; + hexo.config.permalink = ':year/:month/:day/:title'; + + const post = await Post.insert({ + source: 'foo.md', + slug: 'foo', + date: moment('2014-01-02') + }); + + postPermalink(post).should.eql('2014/01/02/foo/'); + + Post.removeById(post._id); + hexo.config.post_asset_folder = false; + }); + + + it('permalink - should end with / or .html - 2', async () => { + hexo.config.post_asset_folder = true; + + const posts = await Post.insert([{ + source: 'my-new-post.md', + slug: 'hexo/permalink-test', + __permalink: 'hexo/permalink-test', + title: 'Permalink Test', + date: moment('2014-01-02') + }, { + source: 'another-new-post.md', + slug: '/hexo-hexo/permalink-test-2', + __permalink: '/hexo-hexo/permalink-test-2/', + title: 'Permalink Test', + date: moment('2014-01-02') + }, { + source: 'another-another-new-post.md', + slug: '/hexo-hexo/permalink-test-3', + __permalink: '/hexo-hexo/permalink-test-3.html', + title: 'Permalink Test', + date: moment('2014-01-02') + }]); + + postPermalink(posts[0]).should.eql('/hexo/permalink-test/'); + postPermalink(posts[1]).should.eql('/hexo-hexo/permalink-test-2/'); + postPermalink(posts[2]).should.eql('/hexo-hexo/permalink-test-3.html'); + + await Promise.all(posts.map(post => Post.removeById(post._id))); + hexo.config.post_asset_folder = false; + }); });