From 576d773fecf5ec6a7ebf5b089ff7a03b102468eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Thu, 18 Feb 2016 12:13:24 +0100 Subject: [PATCH] Correctly map filenames for website output --- lib/output/base.js | 3 ++- test/assertions.js | 2 +- test/mock.js | 2 +- test/output-website.js | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/lib/output/base.js b/lib/output/base.js index e674f4652..09f57bc38 100644 --- a/lib/output/base.js +++ b/lib/output/base.js @@ -184,9 +184,10 @@ Output.prototype.resolveForPage = function(page, href) { // Filename for output // READMEs are replaced by index.html +// /test/README.md -> /test/index.html Output.prototype.outputPath = function(filename, ext) { ext = ext || this.defaultExtension; - var output; + var output = filename; if ( path.basename(filename, path.extname(filename)) == 'README' || diff --git a/test/assertions.js b/test/assertions.js index b9369953d..56da24917 100644 --- a/test/assertions.js +++ b/test/assertions.js @@ -6,7 +6,7 @@ var should = require('should'); // Assertions to test if an Output has generated a file should.Assertion.add('file', function(file, description) { this.params = { - actual: this.obj.toString(), + actual: this.obj.root(), operator: 'have file ' + file, message: description }; diff --git a/test/mock.js b/test/mock.js index fe8ed7ae3..f9cc65789 100644 --- a/test/mock.js +++ b/test/mock.js @@ -68,7 +68,7 @@ function setupDefaultBook(files, summary, opts) { // Output a book with a specific generator function outputDefaultBook(Output, files, summary, opts) { - return setupDefaultBook(files, opts) + return setupDefaultBook(files, summary, opts) .then(function(book) { // Parse the book return book.parse() diff --git a/test/output-website.js b/test/output-website.js index bc15bcc39..9fe1928a1 100644 --- a/test/output-website.js +++ b/test/output-website.js @@ -24,5 +24,38 @@ describe('Website Output', function() { }); + describe('Book with chapters', function() { + var output; + + before(function() { + return mock.outputDefaultBook(WebsiteOutput, { + 'hello/README.md': '# Hello', + 'hello/test.md': '# Test' + }, [ + { + title: 'Hello', + path: 'hello/README.md' + }, + { + title: 'Test', + path: 'hello/test.md' + } + ]) + .then(function(_output) { + output = _output; + }); + }); + + it('should correctly generate an index.html', function() { + output.should.have.file('index.html'); + }); + + it('should correctly generate files in folder', function() { + output.should.have.file('hello/index.html'); + output.should.have.file('hello/test.html'); + }); + + }); + });