From b2e684af8f132a617b808bb6f4b91af04425b63e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Tue, 24 Mar 2015 17:34:47 +0100 Subject: [PATCH] Add test for templating context --- test/templating.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/templating.js diff --git a/test/templating.js b/test/templating.js new file mode 100644 index 000000000..af29d25fe --- /dev/null +++ b/test/templating.js @@ -0,0 +1,33 @@ +var pkg = require("../package.json"); + +describe('Templating', function () { + var book; + + before(function() { + return books.parse("basic") + .then(function(_book) { + book = _book; + }); + }); + + var testTpl = function(str, args, options) { + return book.template.renderString(str, args, options) + .then(book.template.postProcess) + }; + + describe('Context', function() { + it('should correctly have access to generator', function() { + return testTpl('{{ gitbook.generator }}') + .then(function(content) { + content.should.equal("website"); + }); + }); + + it('should correctly have access to gitbook version', function() { + return testTpl('{{ gitbook.version }}') + .then(function(content) { + content.should.equal(pkg.version.toString()); + }); + }); + }); +});