diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-14 23:05:37 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-14 23:05:37 +0100 |
commit | d6bd4a0d67dd2f61e667aefebf96e279f607ce54 (patch) | |
tree | d5a4a12654c6775a1a8924a0b65cff6195fb18b9 /test | |
parent | 8628c87be479015b204520bb058b0cc823859d70 (diff) | |
download | gitbook-d6bd4a0d67dd2f61e667aefebf96e279f607ce54.zip gitbook-d6bd4a0d67dd2f61e667aefebf96e279f607ce54.tar.gz gitbook-d6bd4a0d67dd2f61e667aefebf96e279f607ce54.tar.bz2 |
Add test for file variables in templating
Diffstat (limited to 'test')
-rw-r--r-- | test/all.js | 4 | ||||
-rw-r--r-- | test/page.js | 20 |
2 files changed, 22 insertions, 2 deletions
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 |