Skip to content

Commit

Permalink
fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon committed Feb 7, 2024
1 parent e46db68 commit f89ffb1
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions test/scripts/filters/post_permalink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});

0 comments on commit f89ffb1

Please sign in to comment.