From 4a25cd59fa8e90593912686f4e5ac9c7bd0b9338 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Tue, 16 Jun 2020 17:19:33 +0800 Subject: [PATCH] test(post): add test cases for #3543 & #3459 --- test/scripts/hexo/post.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/scripts/hexo/post.js b/test/scripts/hexo/post.js index 88820e5fe1..918e28a2cb 100644 --- a/test/scripts/hexo/post.js +++ b/test/scripts/hexo/post.js @@ -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 = '
'; + const highlightedJs = highlight(js, { lang: 'js' }); + const highlightedHtml = highlight(html, { lang: 'html' }); + + const content = [ + '```js', + js, + '```', + '{% raw %}', + '

Foo

', + '{% 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('

Foo

'); + data.content.trim().should.not.contains('{% raw %}'); + data.content.trim().should.not.contains('{% endraw %}'); + data.content.trim().should.contains(highlightedHtml); + }); });