diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-19 10:59:43 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-19 10:59:43 +0100 |
commit | 39b2aaf4898921fc845ffa165d038fa58404548d (patch) | |
tree | 251e5344791e60c0a17fadf193af4a5b9e5b84ce /test | |
parent | 58b04da60fd819ad851a0ccc826b45bbbafaa0b5 (diff) | |
download | gitbook-39b2aaf4898921fc845ffa165d038fa58404548d.zip gitbook-39b2aaf4898921fc845ffa165d038fa58404548d.tar.gz gitbook-39b2aaf4898921fc845ffa165d038fa58404548d.tar.bz2 |
Add parsing of summary and associated tests
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/summary/markdown/SUMMARY.md | 11 | ||||
-rw-r--r-- | test/summary.js | 22 |
2 files changed, 33 insertions, 0 deletions
diff --git a/test/fixtures/summary/markdown/SUMMARY.md b/test/fixtures/summary/markdown/SUMMARY.md new file mode 100644 index 0000000..a51deae --- /dev/null +++ b/test/fixtures/summary/markdown/SUMMARY.md @@ -0,0 +1,11 @@ +# Summary + +* [Chapter 1](chapter-1/README.md) + * [Article 1](chapter-1/ARTICLE1.md) + * [Article 2](chapter-1/ARTICLE2.md) + * [article 1.2.1](\chapter-1\ARTICLE-1-2-1.md) + * [article 1.2.2](/chapter-1/ARTICLE-1-2-2.md) +* [Chapter 2](chapter-2/README.md) +* [Chapter 3](chapter-3/README.md) +* [Chapter 4](chapter-4/README.md) + diff --git a/test/summary.js b/test/summary.js new file mode 100644 index 0000000..a90212f --- /dev/null +++ b/test/summary.js @@ -0,0 +1,22 @@ +var path = require('path'); +var assert = require('assert'); + +var Book = require('../').Book; + +describe('Summary parsing', function () { + it('should correctly parse it from markdown', function(done) { + var book = new Book(path.join(__dirname, './fixtures/summary/markdown')); + book.parseSummary() + .then(function() { + var LEXED = book.summary; + + assert.equal(LEXED.chapters[0].path,'README.md'); + assert.equal(LEXED.chapters[1].path,'chapter-1/README.md'); + assert.equal(LEXED.chapters[2].path,'chapter-2/README.md'); + assert.equal(LEXED.chapters[3].path,'chapter-3/README.md'); + }) + .then(function() { + done() + }, done); + }); +}); |