summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-03-24 13:24:20 +0100
committerSamy Pessé <samypesse@gmail.com>2015-03-24 13:24:20 +0100
commit346c05f0de8a06ba07e7644f80aa6b3a7b8254a6 (patch)
tree9c42920068a14ab7ff0e24d1a57f4810561095ae /test
parent73c69923b34b30105750d1e72990d5a9b0ca1596 (diff)
downloadgitbook-346c05f0de8a06ba07e7644f80aa6b3a7b8254a6.zip
gitbook-346c05f0de8a06ba07e7644f80aa6b3a7b8254a6.tar.gz
gitbook-346c05f0de8a06ba07e7644f80aa6b3a7b8254a6.tar.bz2
Add tests for configuration parsing
Diffstat (limited to 'test')
-rw-r--r--test/books/config-js/README.md1
-rw-r--r--test/books/config-js/SUMMARY.md1
-rw-r--r--test/books/config-js/book.js3
-rw-r--r--test/books/config-json/README.md1
-rw-r--r--test/books/config-json/SUMMARY.md1
-rw-r--r--test/books/config-json/book.json3
-rw-r--r--test/configuration.js25
-rw-r--r--test/helper.js1
8 files changed, 36 insertions, 0 deletions
diff --git a/test/books/config-js/README.md b/test/books/config-js/README.md
new file mode 100644
index 0000000..f395431
--- /dev/null
+++ b/test/books/config-js/README.md
@@ -0,0 +1 @@
+# Readme
diff --git a/test/books/config-js/SUMMARY.md b/test/books/config-js/SUMMARY.md
new file mode 100644
index 0000000..ac9323c
--- /dev/null
+++ b/test/books/config-js/SUMMARY.md
@@ -0,0 +1 @@
+# Summary
diff --git a/test/books/config-js/book.js b/test/books/config-js/book.js
new file mode 100644
index 0000000..8731343
--- /dev/null
+++ b/test/books/config-js/book.js
@@ -0,0 +1,3 @@
+module.exports = {
+ "title": "js-config"
+};
diff --git a/test/books/config-json/README.md b/test/books/config-json/README.md
new file mode 100644
index 0000000..f395431
--- /dev/null
+++ b/test/books/config-json/README.md
@@ -0,0 +1 @@
+# Readme
diff --git a/test/books/config-json/SUMMARY.md b/test/books/config-json/SUMMARY.md
new file mode 100644
index 0000000..ac9323c
--- /dev/null
+++ b/test/books/config-json/SUMMARY.md
@@ -0,0 +1 @@
+# Summary
diff --git a/test/books/config-json/book.json b/test/books/config-json/book.json
new file mode 100644
index 0000000..eda10bb
--- /dev/null
+++ b/test/books/config-json/book.json
@@ -0,0 +1,3 @@
+{
+ "title": "json-config"
+}
diff --git a/test/configuration.js b/test/configuration.js
new file mode 100644
index 0000000..f1fb223
--- /dev/null
+++ b/test/configuration.js
@@ -0,0 +1,25 @@
+var fs = require('fs');
+var path = require('path');
+
+describe('Configuration', function () {
+ it('should extract default title from README', function() {
+ return books.parse("basic")
+ .then(function(book) {
+ book.options.title.should.be.equal("Readme");
+ });
+ });
+
+ it('should correctly load from json (book.json)', function() {
+ return books.parse("config-json")
+ .then(function(book) {
+ book.options.title.should.be.equal("json-config");
+ });
+ });
+
+ it('should correctly load from JavaScript (book.js)', function() {
+ return books.parse("config-js")
+ .then(function(book) {
+ book.options.title.should.be.equal("js-config");
+ });
+ });
+});
diff --git a/test/helper.js b/test/helper.js
index 8726667..f6b671b 100644
--- a/test/helper.js
+++ b/test/helper.js
@@ -27,6 +27,7 @@ function generateBook(bookId, test) {
// Generate and return a book
function parseBook(bookId, test) {
+ test = test || "website";
BOOKS[bookId] = BOOKS[bookId] || {};
if (BOOKS[bookId][test]) return Q(BOOKS[bookId][test]);