summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/mock.js12
-rw-r--r--test/page.js21
2 files changed, 25 insertions, 8 deletions
diff --git a/test/mock.js b/test/mock.js
index 127e35c..ce4dca5 100644
--- a/test/mock.js
+++ b/test/mock.js
@@ -49,15 +49,21 @@ function setupBook(files, opts) {
}
// Setup a book with default README/SUMMARY
-function setupDefaultBook(files, opts) {
+function setupDefaultBook(files, summary, opts) {
+ var summaryContent = '# Summary \n\n' +
+ _.map(summary, function(article) {
+ return '* [' + article.title +'](' + article.path + ')';
+ })
+ .join('\n');
+
return setupBook(_.defaults(files || {}, {
'README.md': 'Hello',
- 'SUMMARY.md': '# Summary'
+ 'SUMMARY.md': summaryContent
}), opts);
}
// Output a book with a specific generator
-function outputDefaultBook(Output, files, opts) {
+function outputDefaultBook(Output, files, summary, opts) {
return setupDefaultBook(files, opts)
.then(function(book) {
// Parse the book
diff --git a/test/page.js b/test/page.js
index 9932e38..a9b7985 100644
--- a/test/page.js
+++ b/test/page.js
@@ -10,8 +10,14 @@ describe('Page', function() {
'links.md': '[link](hello.md) [readme](README.md)',
'folder/paths.md': '',
'variables/file/mtime.md': '{{ file.mtime }}',
- 'variables/file/path.md': '{{ file.path }}'
- })
+ 'variables/file/path.md': '{{ file.path }}',
+ 'variables/page/title.md': '{{ page.title }}'
+ }, [
+ {
+ title: 'Test Variables',
+ path: 'variables/page/title.md'
+ }
+ ])
.then(function(_book) {
book = _book;
output = new Output(book);
@@ -95,7 +101,6 @@ describe('Page', function() {
});
});
-
describe('Templating Context', function() {
it('should set file.mtime', function() {
var page = book.addPage('variables/file/mtime.md');
@@ -105,10 +110,16 @@ describe('Page', function() {
});
});
- it('should set file.[path]', function() {
+ 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');
});
+
+ it('should set page.title when page is in summary', function() {
+ var page = book.getPage('variables/page/title.md');
+ return page.toHTML(output)
+ .should.be.fulfilledWith('<p>Test Variables</p>\n');
+ });
});
-}); \ No newline at end of file
+});