Skip to content

Commit d21aa32

Browse files
add unit test for disableNunjucks property of renderer; PR #3573 #3573
1 parent 995097e commit d21aa32

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

test/fixtures/post_render.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,16 @@ exports.expected = [
3737
'<blockquote><p>quote content</p>\n',
3838
'<footer><strong>Hello World</strong></footer></blockquote>'
3939
].join('');
40+
41+
exports.expected_disable_nunjucks = [
42+
'<h1 id="Title"><a href="#Title" class="headerlink" title="Title"></a>Title</h1>',
43+
util.highlight(code, {lang: 'python'}),
44+
'\n\n<p>some content</p>\n',
45+
'<h2 id="Another-title"><a href="#Another-title" class="headerlink" title="Another title"></a>Another title</h2>',
46+
'<p>{% blockquote %}<br>',
47+
'quote content<br>',
48+
'{% endblockquote %}</p>\n',
49+
'<p>{% quote Hello World %}<br>',
50+
'quote content<br>',
51+
'{% endquote %}</p>'
52+
].join('');

test/scripts/hexo/post.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,4 +686,21 @@ describe('Post', () => {
686686
callback();
687687
});
688688
});
689+
690+
// test for PR [#3573](https://github.com/hexojs/hexo/pull/3573)
691+
it('render() - disableNunjucks', () => {
692+
const renderer = hexo.render.renderer.get('markdown');
693+
renderer.disableNunjucks = true;
694+
695+
return post.render(null, {
696+
content: fixture.content,
697+
engine: 'markdown'
698+
}).then(data => {
699+
data.content.trim().should.eql(fixture.expected_disable_nunjucks);
700+
}).then(data => {
701+
renderer.disableNunjucks = false;
702+
});
703+
704+
});
705+
689706
});

0 commit comments

Comments
 (0)