diff options
Diffstat (limited to 'packages/gitbook-html/test')
-rwxr-xr-x | packages/gitbook-html/test/fixtures/SUMMARY.html | 14 | ||||
-rwxr-xr-x | packages/gitbook-html/test/glossary.js | 10 | ||||
-rwxr-xr-x | packages/gitbook-html/test/langs.js | 10 | ||||
-rwxr-xr-x | packages/gitbook-html/test/readme.js | 10 | ||||
-rwxr-xr-x | packages/gitbook-html/test/summary.js | 50 |
5 files changed, 63 insertions, 31 deletions
diff --git a/packages/gitbook-html/test/fixtures/SUMMARY.html b/packages/gitbook-html/test/fixtures/SUMMARY.html index f469249..bae97f3 100755 --- a/packages/gitbook-html/test/fixtures/SUMMARY.html +++ b/packages/gitbook-html/test/fixtures/SUMMARY.html @@ -23,4 +23,16 @@ </ul> </li> <li>Unfinished Chapter</li> -</ul>
\ No newline at end of file +</ul> + +<ul> + <li> + <a href="chapter-1/README.md">Chapter 1</a> + </li> +</ul> + +<ul> + <li> + <a href="chapter-1/README.md">Chapter 1</a> + </li> +</ul> diff --git a/packages/gitbook-html/test/glossary.js b/packages/gitbook-html/test/glossary.js index 250c6f1..8bd77d6 100755 --- a/packages/gitbook-html/test/glossary.js +++ b/packages/gitbook-html/test/glossary.js @@ -4,10 +4,14 @@ var assert = require('assert'); var glossary = require('../').glossary; -var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/GLOSSARY.html'), 'utf8'); -var LEXED = glossary(CONTENT); - describe('Glossary parsing', function () { + var LEXED; + + before(function() { + var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/GLOSSARY.html'), 'utf8'); + LEXED = glossary(CONTENT); + }); + it('should only get heading + paragraph pairs', function() { assert.equal(LEXED.length, 5); }); diff --git a/packages/gitbook-html/test/langs.js b/packages/gitbook-html/test/langs.js index c51cf2d..6b5e00b 100755 --- a/packages/gitbook-html/test/langs.js +++ b/packages/gitbook-html/test/langs.js @@ -4,10 +4,14 @@ var assert = require('assert'); var langs = require('../').langs; -var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/LANGS.html'), 'utf8'); -var LEXED = langs(CONTENT); - describe('Languages parsing', function () { + var LEXED; + + before(function() { + var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/LANGS.html'), 'utf8'); + LEXED = langs(CONTENT); + }); + it('should detect paths and titles', function() { assert.equal(LEXED[0].path,'en/'); assert.equal(LEXED[0].title,'English'); diff --git a/packages/gitbook-html/test/readme.js b/packages/gitbook-html/test/readme.js index 9d9ca29..f38f40b 100755 --- a/packages/gitbook-html/test/readme.js +++ b/packages/gitbook-html/test/readme.js @@ -4,11 +4,13 @@ var assert = require('assert'); var readme = require('../').readme; - -var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/README.html'), 'utf8'); -var LEXED = readme(CONTENT); - describe('Readme parsing', function () { + var LEXED; + + before(function() { + var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/README.html'), 'utf8'); + LEXED = readme(CONTENT); + }); it('should contain a title', function() { assert(LEXED.title); diff --git a/packages/gitbook-html/test/summary.js b/packages/gitbook-html/test/summary.js index 8d686fc..4d06c32 100755 --- a/packages/gitbook-html/test/summary.js +++ b/packages/gitbook-html/test/summary.js @@ -4,37 +4,47 @@ var assert = require('assert'); var summary = require('../').summary; -var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/SUMMARY.html'), 'utf8'); -var LEXED = summary(CONTENT); describe('Summary parsing', function () { + var LEXED, PART; + + before(function() { + var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/SUMMARY.html'), 'utf8'); + LEXED = summary(CONTENT); + PART = LEXED.parts[0]; + }); + + it('should detect parts', function() { + assert.equal(LEXED.parts.length, 3); + }); + 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(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].path); + assert(PART.articles[1].path); + assert(PART.articles[2].path); + assert(PART.articles[3].path); + assert.equal(PART.articles[4].path, null); + + 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 correctly convert it to text', function() { |