summaryrefslogtreecommitdiffstats
path: root/test/template.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-15 14:07:26 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-15 14:07:26 +0100
commit354fe1274242bef87b739dbe43cdb634ea573662 (patch)
treed4a7c1f48878ba4eb6793535cc42a516a143bc0e /test/template.js
parent1b19c6660303cb6ce98ac0ad76580f66b52985f1 (diff)
downloadgitbook-354fe1274242bef87b739dbe43cdb634ea573662.zip
gitbook-354fe1274242bef87b739dbe43cdb634ea573662.tar.gz
gitbook-354fe1274242bef87b739dbe43cdb634ea573662.tar.bz2
Fix addBlock for template engine
Add test for code block
Diffstat (limited to 'test/template.js')
-rw-r--r--test/template.js24
1 files changed, 21 insertions, 3 deletions
diff --git a/test/template.js b/test/template.js
index 536043d..d12a641 100644
--- a/test/template.js
+++ b/test/template.js
@@ -6,9 +6,7 @@ describe('Template', function() {
var output;
before(function() {
- return mock.outputDefaultBook(Output, {
- 'test.md': 'World'
- })
+ return mock.outputDefaultBook(Output, {})
.then(function(_output) {
output = _output;
});
@@ -25,4 +23,24 @@ describe('Template', function() {
.should.be.fulfilledWith('Version is '+pkg.version);
});
});
+
+ describe('Blocks', function() {
+ it('should correctly add a block', function() {
+ output.template.addBlock('sayhello', function(blk) {
+ return 'Hello ' + blk.body + '!';
+ });
+
+ return output.template.renderString('{% sayhello %}World{% endsayhello %}')
+ .should.be.fulfilledWith('Hello World!');
+ });
+
+ it('should correctly add a block with kwargs', function() {
+ output.template.addBlock('sayhello_kwargs', function(blk) {
+ return 'Hello ' + blk.kwargs.name + '!';
+ });
+
+ return output.template.renderString('{% sayhello_kwargs name="World" %}{% endsayhello_kwargs %}')
+ .should.be.fulfilledWith('Hello World!');
+ });
+ });
});