diff options
Diffstat (limited to 'packages/gitbook-markdown/test/summary.js')
-rw-r--r-- | packages/gitbook-markdown/test/summary.js | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/packages/gitbook-markdown/test/summary.js b/packages/gitbook-markdown/test/summary.js index a1bb49a..22800d4 100644 --- a/packages/gitbook-markdown/test/summary.js +++ b/packages/gitbook-markdown/test/summary.js @@ -13,56 +13,57 @@ function lex(fixtureFile) { ); } -var LEXED = lex('SUMMARY.md'); - describe('Summary parsing', function () { + var LEXED; + + before(function() { + LEXED = lex('SUMMARY.md'); + PART = LEXED.parts[0]; + }); + it('should detect chapters', function() { - assert.equal(LEXED.chapters.length, 5); + assert.equal(PART.articles.length, 5); }); it('should support articles', function() { - assert.equal(LEXED.chapters[0].articles.length, 2); - assert.equal(LEXED.chapters[1].articles.length, 0); - assert.equal(LEXED.chapters[2].articles.length, 0); + assert.equal(PART.articles[0].articles.length, 2); + assert.equal(PART.articles[1].articles.length, 0); + assert.equal(PART.articles[2].articles.length, 0); }); it('should detect paths and titles', function() { - assert(LEXED.chapters[0].path); - assert(LEXED.chapters[1].path); - assert(LEXED.chapters[2].path); - assert(LEXED.chapters[3].path); - assert.equal(LEXED.chapters[4].path, null); + assert(PART.articles[0].path); + assert(PART.articles[1].path); + assert(PART.articles[2].path); + assert(PART.articles[3].path); + assert.equal(PART.articles[4].path, null); - assert(LEXED.chapters[0].title); - assert(LEXED.chapters[1].title); - assert(LEXED.chapters[2].title); - assert(LEXED.chapters[3].title); - assert(LEXED.chapters[4].title); + assert(PART.articles[0].title); + assert(PART.articles[1].title); + assert(PART.articles[2].title); + assert(PART.articles[3].title); + assert(PART.articles[4].title); }); it('should normalize paths from .md', function() { - assert.equal(LEXED.chapters[0].path,'chapter-1/README.md'); - assert.equal(LEXED.chapters[1].path,'chapter-2/README.md'); - assert.equal(LEXED.chapters[2].path,'chapter-3/README.md'); + assert.equal(PART.articles[0].path,'chapter-1/README.md'); + assert.equal(PART.articles[1].path,'chapter-2/README.md'); + assert.equal(PART.articles[2].path,'chapter-3/README.md'); + }); + + it('should part parts', function() { + var l = lex('SUMMARY_PARTS.md'); + assert.equal(l.parts.length, 3); }); it('should allow lists separated by whitespace', function() { var l = lex('SUMMARY_WHITESPACE.md'); - assert.equal(l.chapters.length, 5); + assert.equal(l.parts[0].articles.length, 5); }); it('should allow ignore empty entries', function() { var l = lex('SUMMARY_EMPTY.md'); - assert.equal(l.chapters.length, 1); - }); - - it('should throw error for sublist entries', function() { - assert.throws( - function() { - var l = lex('SUMMARY_SUBLIST.md'); - }, - "Invalid entry in the SUMMARY" - ); + assert.equal(l.parts[0].articles.length, 1); }); it('should correctly convert it to text', function() { |