Skip to content

Commit

Permalink
test(post): add test cases for #3543 & #3459 (#4361)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW authored Jun 16, 2020
1 parent d117819 commit a77796a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/scripts/hexo/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -1050,4 +1050,36 @@ describe('Post', () => {
// Re-anable highlight for other tests
hexo.config.highlight.enable = true;
});

// https://github.com/hexojs/hexo/issues/3543
it('render() - issue #3543', async () => {
// Adopted from https://github.com/hexojs/hexo/pull/3459/files
const js = 'alert("Foo")';
const html = '<div></div>';
const highlightedJs = highlight(js, { lang: 'js' });
const highlightedHtml = highlight(html, { lang: 'html' });

const content = [
'```js',
js,
'```',
'{% raw %}',
'<p>Foo</p>',
'{% endraw %}',
'```html',
html,
'```'
].join('\n');

const data = await post.render(null, {
content,
engine: 'markdown'
});

data.content.trim().should.contains(highlightedJs);
data.content.trim().should.contains('<p>Foo</p>');
data.content.trim().should.not.contains('{% raw %}');
data.content.trim().should.not.contains('{% endraw %}');
data.content.trim().should.contains(highlightedHtml);
});
});

0 comments on commit a77796a

Please sign in to comment.