diff options
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | test/assertions.js | 4 | ||||
-rw-r--r-- | test/books/summary/PAGE1.md | 1 | ||||
-rw-r--r-- | test/books/summary/README.md | 1 | ||||
-rw-r--r-- | test/books/summary/SUMMARY.md | 5 | ||||
-rw-r--r-- | test/books/summary/folder/PAGE2.md | 1 | ||||
-rw-r--r-- | test/summary.js | 45 |
7 files changed, 56 insertions, 3 deletions
diff --git a/package.json b/package.json index 69ccaa1..b16123b 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "resolve": "0.6.3", "fs-extra": "0.16.5", "fstream-ignore": "1.0.2", - "gitbook-parsers": "0.6.0", + "gitbook-parsers": "0.7.0", "nunjucks": "git+https://github.com/mozilla/nunjucks.git#0f8b21b8df7e8e852b2e1889388653b7075f0d09", "nunjucks-autoescape": "0.1.1", "nunjucks-filter": "0.1.0", diff --git a/test/assertions.js b/test/assertions.js index 8bb440f..83465e1 100644 --- a/test/assertions.js +++ b/test/assertions.js @@ -5,7 +5,7 @@ var should = require('should'); var cheerio = require('cheerio'); should.Assertion.add('file', function(file, description) { - this.params = { operator: 'have file ' + file, message: description }; + this.params = { actual: this.obj.toString(), operator: 'have file ' + file, message: description }; this.obj.should.have.property('options').which.is.an.Object; this.obj.options.should.have.property('output').which.is.a.String; @@ -13,7 +13,7 @@ should.Assertion.add('file', function(file, description) { }); should.Assertion.add('jsonfile', function(file, description) { - this.params = { operator: 'have valid jsonfile ' + file, message: description }; + this.params = { actual: this.obj.toString(), operator: 'have valid jsonfile ' + file, message: description }; this.obj.should.have.property('options').which.is.an.Object; this.obj.options.should.have.property('output').which.is.a.String; diff --git a/test/books/summary/PAGE1.md b/test/books/summary/PAGE1.md new file mode 100644 index 0000000..9608001 --- /dev/null +++ b/test/books/summary/PAGE1.md @@ -0,0 +1 @@ +# Page 1 diff --git a/test/books/summary/README.md b/test/books/summary/README.md new file mode 100644 index 0000000..f395431 --- /dev/null +++ b/test/books/summary/README.md @@ -0,0 +1 @@ +# Readme diff --git a/test/books/summary/SUMMARY.md b/test/books/summary/SUMMARY.md new file mode 100644 index 0000000..38d0f6b --- /dev/null +++ b/test/books/summary/SUMMARY.md @@ -0,0 +1,5 @@ +# Summary + +* [Page 1](./PAGE1.md) +* [Page 2](./folder/PAGE2.md) +* [Don't exists](./NOTFOUND.md) diff --git a/test/books/summary/folder/PAGE2.md b/test/books/summary/folder/PAGE2.md new file mode 100644 index 0000000..f310be3 --- /dev/null +++ b/test/books/summary/folder/PAGE2.md @@ -0,0 +1 @@ +# Page 2 diff --git a/test/summary.js b/test/summary.js new file mode 100644 index 0000000..3837651 --- /dev/null +++ b/test/summary.js @@ -0,0 +1,45 @@ +var fs = require('fs'); +var path = require('path'); + +describe('Summary', function () { + describe('Parsing', function() { + var book; + + before(function() { + return books.parse("summary", "website") + .then(function(_book) { + book = _book; + }); + }); + + it('should correctly list items', function() { + book.should.have.property("summary"); + book.summary.should.have.property("chapters"); + book.summary.chapters.should.have.lengthOf(4); + }); + + it('should correctly mark non-existant entries', function() { + book.summary.chapters[0].exists.should.have.equal(true); + book.summary.chapters[1].exists.should.have.equal(true); + book.summary.chapters[2].exists.should.have.equal(true); + book.summary.chapters[3].exists.should.have.equal(false); + }); + }); + + describe('Generation', function() { + var book; + + before(function() { + return books.generate("summary", "website") + .then(function(_book) { + book = _book; + }); + }); + + it('should create files according to summary', function() { + book.should.have.file("index.html"); + book.should.have.file("PAGE1.html"); + book.should.have.file("folder/PAGE2.html"); + }); + }); +}); |