summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/summary/markdown/SUMMARY.md11
-rw-r--r--test/summary.js22
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);
+ });
+});