diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-05-09 22:01:25 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-05-09 22:01:25 +0200 |
commit | f8bb55f2582df2a6b9203d43d2e3628a7ec529a1 (patch) | |
tree | 36329666b8891edc80feb4f2f1070fc56d343384 /lib/models | |
parent | 76daebeb840a512dddca5d844383d0262d9a9f5a (diff) | |
download | gitbook-f8bb55f2582df2a6b9203d43d2e3628a7ec529a1.zip gitbook-f8bb55f2582df2a6b9203d43d2e3628a7ec529a1.tar.gz gitbook-f8bb55f2582df2a6b9203d43d2e3628a7ec529a1.tar.bz2 |
Adapt unit tests for blocks
Diffstat (limited to 'lib/models')
-rw-r--r-- | lib/models/__tests__/templateBlock.js | 30 | ||||
-rw-r--r-- | lib/models/templateBlock.js | 2 |
2 files changed, 26 insertions, 6 deletions
diff --git a/lib/models/__tests__/templateBlock.js b/lib/models/__tests__/templateBlock.js index 52f6407..5265bf6 100644 --- a/lib/models/__tests__/templateBlock.js +++ b/lib/models/__tests__/templateBlock.js @@ -8,7 +8,10 @@ describe('TemplateBlock', function() { describe('create', function() { pit('must initialize a simple TemplateBlock from a function', function() { var templateBlock = TemplateBlock.create('sayhello', function(block) { - return '<p>Hello, World!</p>'; + return { + body: '<p>Hello, World!</p>', + parse: true + }; }); // Check basic templateBlock properties @@ -32,7 +35,10 @@ describe('TemplateBlock', function() { describe('getShortcuts', function() { it('must return undefined if no shortcuts', function() { var templateBlock = TemplateBlock.create('sayhello', function(block) { - return '<p>Hello, World!</p>'; + return { + body: '<p>Hello, World!</p>', + parse: true + }; }); expect(templateBlock.getShortcuts()).not.toBeDefined(); @@ -63,7 +69,10 @@ describe('TemplateBlock', function() { describe('toNunjucksExt()', function() { pit('must create a valid nunjucks extension', function() { var templateBlock = TemplateBlock.create('sayhello', function(block) { - return '<p>Hello, World!</p>'; + return { + body: '<p>Hello, World!</p>', + parse: true + }; }); // Create a fresh Nunjucks environment @@ -83,7 +92,10 @@ describe('TemplateBlock', function() { pit('must apply block arguments correctly', function() { var templateBlock = TemplateBlock.create('sayhello', function(block) { - return '<'+block.kwargs.tag+'>Hello, '+block.kwargs.name+'!</'+block.kwargs.tag+'>'; + return { + body: '<'+block.kwargs.tag+'>Hello, '+block.kwargs.name+'!</'+block.kwargs.tag+'>', + parse: true + }; }); // Create a fresh Nunjucks environment @@ -105,7 +117,10 @@ describe('TemplateBlock', function() { var templateBlock = TemplateBlock.create('sayhello', function(block) { return Promise() .then(function() { - return 'Hello ' + block.body; + return { + body: 'Hello ' + block.body, + parse: true + }; }); }); @@ -135,7 +150,10 @@ describe('TemplateBlock', function() { nested[blk.name] = blk.body.trim(); }); - return '<p class="yoda">'+nested.end+' '+nested.start+'</p>'; + return { + body: '<p class="yoda">'+nested.end+' '+nested.start+'</p>', + parse: true + }; } }); diff --git a/lib/models/templateBlock.js b/lib/models/templateBlock.js index ab4cf3e..36f7c5b 100644 --- a/lib/models/templateBlock.js +++ b/lib/models/templateBlock.js @@ -71,6 +71,8 @@ TemplateBlock.prototype.getExtensionName = function() { @return {Nunjucks.Extension} */ TemplateBlock.prototype.toNunjucksExt = function(mainContext, blocksOutput) { + blocksOutput = blocksOutput || {}; + var that = this; var name = this.getName(); var endTag = this.getEndTag(); |