summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/1-config.js (renamed from test/config.js)0
-rw-r--r--test/2-readme.js43
-rw-r--r--test/3-glossary.js71
-rw-r--r--test/4-langs.js35
-rw-r--r--test/6-parse.js (renamed from test/parse.js)2
-rw-r--r--test/glossary.js75
-rw-r--r--test/readme.js47
7 files changed, 149 insertions, 124 deletions
diff --git a/test/config.js b/test/1-config.js
index 474ffea..474ffea 100644
--- a/test/config.js
+++ b/test/1-config.js
diff --git a/test/2-readme.js b/test/2-readme.js
new file mode 100644
index 0000000..16aa81a
--- /dev/null
+++ b/test/2-readme.js
@@ -0,0 +1,43 @@
+var mock = require('./mock');
+
+describe('Readme', function() {
+ it('should parse empty readme', function() {
+ return mock.setupDefaultBook({
+ 'README.md': ''
+ })
+ .then(function(book) {
+ return book.prepareConfig()
+
+ .then(function() {
+ return book.readme.load();
+ });
+ });
+ });
+
+ it('should parse readme', function() {
+ return mock.setupDefaultBook({
+ 'README.md': '# Hello World\nThis is my book'
+ })
+ .then(function(book) {
+ return book.readme.load()
+ .then(function() {
+ book.readme.title.should.equal('Hello World');
+ book.readme.description.should.equal('This is my book');
+ });
+ });
+ });
+
+ it('should parse AsciiDoc readme', function() {
+ return mock.setupBook({
+ 'README.adoc': '# Hello World\n\nThis is my book\n'
+ })
+ .then(function(book) {
+ return book.readme.load()
+ .then(function() {
+ book.readme.title.should.equal('Hello World');
+ book.readme.description.should.equal('This is my book');
+ });
+ });
+ });
+});
+
diff --git a/test/3-glossary.js b/test/3-glossary.js
new file mode 100644
index 0000000..176298f
--- /dev/null
+++ b/test/3-glossary.js
@@ -0,0 +1,71 @@
+var should = require('should');
+var mock = require('./mock');
+
+describe('Glossary', 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);
+ });
+ });
+
+ describe('glossary.find', function() {
+ it('should return an existing entry', function() {
+ var entry = book.glossary.find('HeLLo World');
+ should.exist(entry);
+ entry.id.should.equal('hello_world');
+ });
+
+ it('should undefined return non existing entry', function() {
+ var entry = book.glossary.find('Hello');
+ should.not.exist(entry);
+ });
+ });
+ });
+});
+
diff --git a/test/4-langs.js b/test/4-langs.js
new file mode 100644
index 0000000..599cb43
--- /dev/null
+++ b/test/4-langs.js
@@ -0,0 +1,35 @@
+var mock = require('./mock');
+
+describe('Langs', function() {
+ it('should parse empty langs', function() {
+ return mock.setupDefaultBook({
+ 'LANGS.md': ''
+ })
+ .then(function(book) {
+ return book.prepareConfig()
+
+ .then(function() {
+ return book.langs.load();
+ })
+
+ .then(function() {
+ book.langs.count().should.equal(0);
+ });
+ });
+ });
+
+ it('should parse languages list', function() {
+ return mock.setupDefaultBook({
+ 'LANGS.md': '# Languages\n\n'
+ + '* [en](./en)\n'
+ + '* [fr](./fr)\n\n'
+ })
+ .then(function(book) {
+ return book.langs.load()
+ .then(function() {
+ book.langs.count().should.equal(2);
+ });
+ });
+ });
+});
+
diff --git a/test/parse.js b/test/6-parse.js
index dca780e..422744d 100644
--- a/test/parse.js
+++ b/test/6-parse.js
@@ -1,7 +1,6 @@
var mock = require('./mock');
describe('Parsing', function() {
-
it('should fail without SUMMARY', function() {
return mock.setupBook({
'README.md': ''
@@ -19,6 +18,5 @@ describe('Parsing', function() {
return book.parse().should.be.rejected;
});
});
-
});
diff --git a/test/glossary.js b/test/glossary.js
deleted file mode 100644
index 116eabf..0000000
--- a/test/glossary.js
+++ /dev/null
@@ -1,75 +0,0 @@
-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);
- });
- });
-
- describe('glossary.find', function() {
- it('should return an existing entry', function() {
- var entry = book.glossary.find('HeLLo World');
- should.exist(entry);
- entry.id.should.equal('hello_world');
- });
-
- it('should undefined return non existing entry', function() {
- var entry = book.glossary.find('Hello');
- should.not.exist(entry);
- });
- });
- });
- });
-
-});
-
diff --git a/test/readme.js b/test/readme.js
deleted file mode 100644
index fd084cb..0000000
--- a/test/readme.js
+++ /dev/null
@@ -1,47 +0,0 @@
-var mock = require('./mock');
-
-describe('Readme', function() {
-
- describe('Parsing', function() {
- it('should parse empty readme', function() {
- return mock.setupDefaultBook({
- 'README.md': ''
- })
- .then(function(book) {
- return book.prepareConfig()
-
- .then(function() {
- return book.readme.load();
- });
- });
- });
-
- it('should parse readme', function() {
- return mock.setupDefaultBook({
- 'README.md': '# Hello World\nThis is my book'
- })
- .then(function(book) {
- return book.readme.load()
- .then(function() {
- book.readme.title.should.equal('Hello World');
- book.readme.description.should.equal('This is my book');
- });
- });
- });
-
- it('should parse AsciiDoc readme', function() {
- return mock.setupBook({
- 'README.adoc': '# Hello World\n\nThis is my book\n'
- })
- .then(function(book) {
- return book.readme.load()
- .then(function() {
- book.readme.title.should.equal('Hello World');
- book.readme.description.should.equal('This is my book');
- });
- });
- });
- });
-
-});
-