diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/summary/markdown/SUMMARY.md | 11 | ||||
-rw-r--r-- | test/fixtures/test1/README.md | 4 | ||||
-rw-r--r-- | test/fixtures/test1/SUMMARY.md | 6 | ||||
-rw-r--r-- | test/fixtures/test1/book.json | 5 | ||||
-rw-r--r-- | test/fixtures/test1/intro.md | 4 | ||||
-rw-r--r-- | test/helper.js | 19 | ||||
-rw-r--r-- | test/parsing.js | 14 | ||||
-rw-r--r-- | test/summary.js | 22 |
8 files changed, 52 insertions, 33 deletions
diff --git a/test/fixtures/summary/markdown/SUMMARY.md b/test/fixtures/summary/markdown/SUMMARY.md deleted file mode 100644 index a51deae..0000000 --- a/test/fixtures/summary/markdown/SUMMARY.md +++ /dev/null @@ -1,11 +0,0 @@ -# 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/fixtures/test1/README.md b/test/fixtures/test1/README.md new file mode 100644 index 0000000..2f7a8d4 --- /dev/null +++ b/test/fixtures/test1/README.md @@ -0,0 +1,4 @@ +# Test + +This file is not parsed by gitbook because the structure is defined in book.json. + diff --git a/test/fixtures/test1/SUMMARY.md b/test/fixtures/test1/SUMMARY.md new file mode 100644 index 0000000..4adaf3e --- /dev/null +++ b/test/fixtures/test1/SUMMARY.md @@ -0,0 +1,6 @@ +# Summary + +* [Chapter 1](test.md) + * [Article 1](test1.md) +* [Chapter 2](test2.md) + diff --git a/test/fixtures/test1/book.json b/test/fixtures/test1/book.json new file mode 100644 index 0000000..82c15c3 --- /dev/null +++ b/test/fixtures/test1/book.json @@ -0,0 +1,5 @@ +{ + "structure": { + "readme": "intro.md" + } +}
\ No newline at end of file diff --git a/test/fixtures/test1/intro.md b/test/fixtures/test1/intro.md new file mode 100644 index 0000000..bf9a1cf --- /dev/null +++ b/test/fixtures/test1/intro.md @@ -0,0 +1,4 @@ +# My Book + +Test description + diff --git a/test/helper.js b/test/helper.js new file mode 100644 index 0000000..f80edcb --- /dev/null +++ b/test/helper.js @@ -0,0 +1,19 @@ +var path = require('path'); +var Q = require('q'); +var Book = require('../').Book; + +// Nicety for mocha / Q +global.qdone = function qdone(promise, done) { + return promise.then(function() { + return done(); + }, function(err) { + return done(err); + }).done(); +}; + +// Init before doing tests +before(function(done) { + global.book1 = new Book(path.join(__dirname, './fixtures/test1')); + + qdone(global.book1.init(), done); +}); diff --git a/test/parsing.js b/test/parsing.js new file mode 100644 index 0000000..3d41939 --- /dev/null +++ b/test/parsing.js @@ -0,0 +1,14 @@ +var path = require('path'); +var assert = require('assert'); + +var Book = require('../').Book; + +describe('Book parsing', function () { + it('should correctly parse it from markdown', function() { + var LEXED = book1.summary; + + assert.equal(LEXED.chapters[0].path,'intro.md'); + assert.equal(LEXED.chapters[1].path,'test.md'); + assert.equal(LEXED.chapters[2].path,'test2.md'); + }); +}); diff --git a/test/summary.js b/test/summary.js deleted file mode 100644 index a90212f..0000000 --- a/test/summary.js +++ /dev/null @@ -1,22 +0,0 @@ -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); - }); -}); |