diff options
author | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-06-15 23:19:28 -0700 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-06-15 23:19:28 -0700 |
commit | ce6b2bc47dfe5d36c31d8c5ec25f2b3a8c2ef6a8 (patch) | |
tree | 229a6650b6e1b51a4047a9625b53d816b83408af | |
parent | 3245d7e430ee309961d40c1c03b4c15dac4ec232 (diff) | |
download | gitbook-ce6b2bc47dfe5d36c31d8c5ec25f2b3a8c2ef6a8.zip gitbook-ce6b2bc47dfe5d36c31d8c5ec25f2b3a8c2ef6a8.tar.gz gitbook-ce6b2bc47dfe5d36c31d8c5ec25f2b3a8c2ef6a8.tar.bz2 |
Add extra navigation tests for #318
-rw-r--r-- | test/fixtures/ALTERNATIVE_SUMMARY.md | 13 | ||||
-rw-r--r-- | test/navigation.js | 16 |
2 files changed, 29 insertions, 0 deletions
diff --git a/test/fixtures/ALTERNATIVE_SUMMARY.md b/test/fixtures/ALTERNATIVE_SUMMARY.md new file mode 100644 index 0000000..e0d0114 --- /dev/null +++ b/test/fixtures/ALTERNATIVE_SUMMARY.md @@ -0,0 +1,13 @@ +# Summary + +* [Custom name for Introduction](README.md) +* [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) + * Unfinished article +* Unfinished Chapter diff --git a/test/navigation.js b/test/navigation.js index 0330d74..47f4bb4 100644 --- a/test/navigation.js +++ b/test/navigation.js @@ -7,7 +7,9 @@ var navigation = require('../').parse.navigation; var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/SUMMARY.md'), 'utf8'); +var ALT_CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/SUMMARY.md'), 'utf8'); var LEXED = summary(CONTENT); +var ALT_LEXED = summary(ALT_CONTENT); describe('Summary navigation', function() { @@ -76,6 +78,20 @@ describe('Summary navigation', function() { assert.equal(nav['chapter-3/README.md'].level, '3'); }); + it('should have a default README node', function() { + var nav = navigation(LEXED); + + assert.equal(nav['README.md'].level, '0'); + assert.equal(nav['README.md'].title, 'Introduction'); + }); + + it('Should allow README node to be customized', function() { + var nav = navigation(ALT_LEXED); + + assert(nav['README.md']); + assert.notEqual(nav['README.md'].title, 'Introduction'); + }); + it('should not accept null paths', function() { var nav = navigation(LEXED); |