summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-14 23:05:37 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-14 23:05:37 +0100
commitd6bd4a0d67dd2f61e667aefebf96e279f607ce54 (patch)
treed5a4a12654c6775a1a8924a0b65cff6195fb18b9
parent8628c87be479015b204520bb058b0cc823859d70 (diff)
downloadgitbook-d6bd4a0d67dd2f61e667aefebf96e279f607ce54.zip
gitbook-d6bd4a0d67dd2f61e667aefebf96e279f607ce54.tar.gz
gitbook-d6bd4a0d67dd2f61e667aefebf96e279f607ce54.tar.bz2
Add test for file variables in templating
-rw-r--r--lib/page/index.js5
-rw-r--r--test/all.js4
-rw-r--r--test/page.js20
3 files changed, 27 insertions, 2 deletions
diff --git a/lib/page/index.js b/lib/page/index.js
index 51416f0..54255dd 100644
--- a/lib/page/index.js
+++ b/lib/page/index.js
@@ -173,6 +173,11 @@ Page.prototype.toHTML = function(output) {
return pipeline.output()
.then(that.update);
+ })
+
+ // Return content itself
+ .then(function() {
+ return that.content;
});
};
diff --git a/test/all.js b/test/all.js
index 2c87155..fed3f61 100644
--- a/test/all.js
+++ b/test/all.js
@@ -5,13 +5,15 @@ require('./readme');
require('./summary');
require('./glossary');
require('./langs');
-require('./page');
require('./parse');
require('./git');
require('./template');
require('./conrefs');
+// Page and HTML generation
+require('./page');
+
// Output
require('./output-json');
require('./assets-inliner');
diff --git a/test/page.js b/test/page.js
index 8dbfe8b..9932e38 100644
--- a/test/page.js
+++ b/test/page.js
@@ -8,7 +8,9 @@ describe('Page', function() {
return mock.setupDefaultBook({
'heading.md': '# Hello\n\n## World',
'links.md': '[link](hello.md) [readme](README.md)',
- 'folder/paths.md': ''
+ 'folder/paths.md': '',
+ 'variables/file/mtime.md': '{{ file.mtime }}',
+ 'variables/file/path.md': '{{ file.path }}'
})
.then(function(_book) {
book = _book;
@@ -93,4 +95,20 @@ describe('Page', function() {
});
});
+
+ describe('Templating Context', function() {
+ it('should set file.mtime', function() {
+ var page = book.addPage('variables/file/mtime.md');
+ return page.toHTML(output)
+ .then(function(content) {
+ content.should.endWith('(CET)</p>\n');
+ });
+ });
+
+ it('should set file.[path]', function() {
+ var page = book.addPage('variables/file/path.md');
+ return page.toHTML(output)
+ .should.be.fulfilledWith('<p>variables/file/path.md</p>\n');
+ });
+ });
}); \ No newline at end of file