summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-01-27 22:48:23 +0100
committerSamy Pessé <samypesse@gmail.com>2016-01-27 22:48:23 +0100
commitddc99104d4394cc21eaa615b01d73ec001ac7a16 (patch)
tree9855406d0a162cf744576c91501480f0450324c7 /test
parent8d277e9108afa6a027c61feb581a2150958f8571 (diff)
downloadgitbook-ddc99104d4394cc21eaa615b01d73ec001ac7a16.zip
gitbook-ddc99104d4394cc21eaa615b01d73ec001ac7a16.tar.gz
gitbook-ddc99104d4394cc21eaa615b01d73ec001ac7a16.tar.bz2
Add unit tests for glossary parsing
Diffstat (limited to 'test')
-rw-r--r--test/glossary.js80
1 files changed, 80 insertions, 0 deletions
diff --git a/test/glossary.js b/test/glossary.js
new file mode 100644
index 0000000..e2c9e2b
--- /dev/null
+++ b/test/glossary.js
@@ -0,0 +1,80 @@
+var should = require('should');
+var mock = require('./mock');
+
+describe('Glossary', function() {
+
+ describe('Parsing', function() {
+ it('should parse empty glossary', function() {
+ return mock.setupDefaultBook({
+ 'GLOSSARY.md': ''
+ })
+ .then(function(book) {
+ return book.prepareConfig()
+
+ .then(function() {
+ return book.glossary.load();
+ })
+ .then(function() {
+ book.glossary.isEmpty().should.be.true();
+ });
+ });
+ });
+
+ describe('Non-empty glossary', function() {
+ var book;
+
+ before(function() {
+ return mock.setupDefaultBook({
+ 'GLOSSARY.md': '# Glossary\n\n### Hello World\n\nThis is an entry'
+ })
+ .then(function(_book) {
+ book = _book;
+ return book.prepareConfig();
+ })
+ .then(function() {
+ return book.glossary.load();
+ });
+ });
+
+ it('should not be empty', function() {
+ book.glossary.isEmpty().should.be.false();
+ });
+
+ describe('glossary.get', function() {
+ it('should return an existing entry', function() {
+ var entry = book.glossary.get('hello_world');
+ should.exist(entry);
+
+ entry.name.should.equal('Hello World');
+ entry.description.should.equal('This is an entry');
+ entry.id.should.equal('hello_world');
+ });
+
+ it('should undefined return non existing entry', function() {
+ var entry = book.glossary.get('cool');
+ should.not.exist(entry);
+ });
+ });
+ });
+
+ it('should parse glossary entries', function() {
+ return mock.setupDefaultBook({
+ 'GLOSSARY.md': '# Glossary\n\n### Hello World\n\nThis is an entry'
+ })
+ .then(function(book) {
+ return book.prepareConfig()
+
+ .then(function() {
+ return book.glossary.load();
+ })
+ .then(function() {
+
+
+
+ });
+ });
+ });
+ });
+
+});
+