diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-19 10:26:48 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-12-22 15:00:28 +0100 |
commit | 58b771ec31c556c83f4ae8f6f1e08610b6ced082 (patch) | |
tree | 462baee9a94c588af6c4178d9e38899b9697ff30 /packages/gitbook-markdown/test | |
parent | 3f1041209582c26abc595be9c2c99189f5b85f3f (diff) | |
download | gitbook-58b771ec31c556c83f4ae8f6f1e08610b6ced082.zip gitbook-58b771ec31c556c83f4ae8f6f1e08610b6ced082.tar.gz gitbook-58b771ec31c556c83f4ae8f6f1e08610b6ced082.tar.bz2 |
Add glossary parser and associated tests
Diffstat (limited to 'packages/gitbook-markdown/test')
-rw-r--r-- | packages/gitbook-markdown/test/fixtures/GLOSSARY.md | 30 | ||||
-rw-r--r-- | packages/gitbook-markdown/test/glossary.js | 20 | ||||
-rw-r--r-- | packages/gitbook-markdown/test/summary.js | 3 |
3 files changed, 50 insertions, 3 deletions
diff --git a/packages/gitbook-markdown/test/fixtures/GLOSSARY.md b/packages/gitbook-markdown/test/fixtures/GLOSSARY.md new file mode 100644 index 0000000..5969902 --- /dev/null +++ b/packages/gitbook-markdown/test/fixtures/GLOSSARY.md @@ -0,0 +1,30 @@ +# Magic +Sufficiently advanced technology, beyond the understanding of the observer producing a sense of wonder. + +Hello, I am random noise in the middle of this beautiful Glossary. (Really astonishing !) + +# PHP +An atrocious language, invented for the sole purpose of inflicting pain and suffering amongst the proframming wizards of this world. + +# Clojure +Lisp re-invented for hipsters. + +# Go +Go Go Google [Wow](https://www.google.com) + +Fantastic, I love code too ! : + +```py + +def f(x): + return x * 4 + +# Wow this is some really awesome code +# totally mind blowing +# but we don't care, it shouldn't be in our glossary ! +print(f(9)) +``` + +# Gitbook + +Awesome project. Really amazing, I'm really at a loss for words ... diff --git a/packages/gitbook-markdown/test/glossary.js b/packages/gitbook-markdown/test/glossary.js new file mode 100644 index 0000000..bf40e16 --- /dev/null +++ b/packages/gitbook-markdown/test/glossary.js @@ -0,0 +1,20 @@ +var fs = require('fs'); +var path = require('path'); +var assert = require('assert'); + +var glossary = require('../').parse.glossary; + +var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/GLOSSARY.md'), 'utf8'); +var LEXED = glossary(CONTENT); + +describe('Glossary parsing', function () { + it('should only get heading + paragraph pairs', function() { + assert.equal(LEXED.length, 5); + }); + + it('should output simple name/description objects', function() { + assert.equal(true, !(LEXED.some(function(e) { + return !Boolean(e.name && e.description); + }))); + }); +}); diff --git a/packages/gitbook-markdown/test/summary.js b/packages/gitbook-markdown/test/summary.js index 2993817..18018b7 100644 --- a/packages/gitbook-markdown/test/summary.js +++ b/packages/gitbook-markdown/test/summary.js @@ -4,13 +4,10 @@ var assert = require('assert'); var summary = require('../').parse.summary; - var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/SUMMARY.md'), 'utf8'); var LEXED = summary(CONTENT); - describe('Summary parsing', function () { - it('should detect chapters', function() { assert.equal(LEXED.chapters.length, 6); }); |