diff options
Diffstat (limited to 'packages/gitbook-asciidoc/test')
-rwxr-xr-x | packages/gitbook-asciidoc/test/glossary.js | 10 | ||||
-rw-r--r-- | packages/gitbook-asciidoc/test/helper.js | 2 | ||||
-rwxr-xr-x | packages/gitbook-asciidoc/test/langs.js | 10 | ||||
-rwxr-xr-x | packages/gitbook-asciidoc/test/page.js | 18 | ||||
-rwxr-xr-x | packages/gitbook-asciidoc/test/readme.js | 10 | ||||
-rwxr-xr-x | packages/gitbook-asciidoc/test/summary.js | 54 |
6 files changed, 60 insertions, 44 deletions
diff --git a/packages/gitbook-asciidoc/test/glossary.js b/packages/gitbook-asciidoc/test/glossary.js index 529bfba..abef367 100755 --- a/packages/gitbook-asciidoc/test/glossary.js +++ b/packages/gitbook-asciidoc/test/glossary.js @@ -4,10 +4,14 @@ var assert = require('assert'); var glossary = require('../').glossary; -var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/GLOSSARY.adoc'), 'utf8'); -var LEXED = glossary(CONTENT); - describe('Glossary parsing', function () { + var LEXED; + + before(function() { + var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/GLOSSARY.adoc'), 'utf8'); + LEXED = glossary(CONTENT); + }); + it('should only get heading + paragraph pairs', function() { assert.equal(LEXED.length, 5); }); diff --git a/packages/gitbook-asciidoc/test/helper.js b/packages/gitbook-asciidoc/test/helper.js index 44cfb24..1e310f7 100644 --- a/packages/gitbook-asciidoc/test/helper.js +++ b/packages/gitbook-asciidoc/test/helper.js @@ -1,6 +1,6 @@ var assert = require("assert"); global.assertObjectsEqual = function(o1, o2) { - assert.equal(JSON.stringify(o1, null, 4), JSON.stringify(o2, null, 4)); + assert.equal(JSON.stringify(o1, null, 4), JSON.stringify(o2, null, 4)); }; diff --git a/packages/gitbook-asciidoc/test/langs.js b/packages/gitbook-asciidoc/test/langs.js index 178c3cc..94111e3 100755 --- a/packages/gitbook-asciidoc/test/langs.js +++ b/packages/gitbook-asciidoc/test/langs.js @@ -4,10 +4,14 @@ var assert = require('assert'); var langs = require('../').langs; -var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/LANGS.adoc'), 'utf8'); -var LEXED = langs(CONTENT); - describe('Languages parsing', function () { + var LEXED; + + before(function() { + var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/LANGS.adoc'), '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-asciidoc/test/page.js b/packages/gitbook-asciidoc/test/page.js index 9579725..3a28c5f 100755 --- a/packages/gitbook-asciidoc/test/page.js +++ b/packages/gitbook-asciidoc/test/page.js @@ -4,19 +4,15 @@ var assert = require('assert'); var page = require('../').page; -function loadPage (name, options) { - var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/' + name + '.adoc'), 'utf8'); - return page(CONTENT, options).sections; -} - -var LEXED = loadPage('PAGE'); - describe('Page parsing', function() { - it('should detect sections', function() { - assert.equal(LEXED.length, 1); + var LEXED; + + before(function() { + var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/PAGE.adoc'), 'utf8'); + LEXED = page(CONTENT); }); - it('should gen content for normal sections', function() { - assert(LEXED[0].content); + it('should gen content', function() { + assert(LEXED.content); }); }); diff --git a/packages/gitbook-asciidoc/test/readme.js b/packages/gitbook-asciidoc/test/readme.js index 0bca343..2f4f601 100755 --- a/packages/gitbook-asciidoc/test/readme.js +++ b/packages/gitbook-asciidoc/test/readme.js @@ -4,11 +4,13 @@ var assert = require('assert'); var readme = require('../').readme; - -var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/README.adoc'), 'utf8'); -var LEXED = readme(CONTENT); - describe('Readme parsing', function () { + var LEXED; + + before(function() { + var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/README.adoc'), 'utf8'); + LEXED = readme(CONTENT); + }); it('should contain a title', function() { assert(LEXED.title); diff --git a/packages/gitbook-asciidoc/test/summary.js b/packages/gitbook-asciidoc/test/summary.js index d363f3f..981967a 100755 --- a/packages/gitbook-asciidoc/test/summary.js +++ b/packages/gitbook-asciidoc/test/summary.js @@ -4,38 +4,48 @@ var assert = require('assert'); var summary = require('../').summary; -var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/SUMMARY.adoc'), 'utf8'); -var LEXED = summary(CONTENT); - describe('Summary parsing', function () { - it('should detect chapters', function() { - assert.equal(LEXED.chapters.length, 5); + var LEXED, PART; + + before(function() { + var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/SUMMARY.adoc'), 'utf8'); + LEXED = summary(CONTENT); + PART = LEXED.parts[0]; + // todo: add support for parts in asciidoc + }); + + it('should detect parts', function() { + assert.equal(LEXED.parts.length, 1); + }); + + it('should detect articles', function() { + 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.adoc'); - assert.equal(LEXED.chapters[1].path,'chapter-2/README.adoc'); - assert.equal(LEXED.chapters[2].path,'chapter-3/README.adoc'); + assert.equal(PART.articles[0].path,'chapter-1/README.adoc'); + assert.equal(PART.articles[1].path,'chapter-2/README.adoc'); + assert.equal(PART.articles[2].path,'chapter-3/README.adoc'); }); it('should correctly convert it to text', function() { |