summaryrefslogtreecommitdiffstats
path: root/test/json.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-03-09 10:43:12 +0100
committerSamy Pessé <samypesse@gmail.com>2015-03-09 10:43:12 +0100
commit34fc2831e0cf0fed01c71cec28d93472d87f455b (patch)
treea803cc907c20491ba02863b5d3dd5aedf6bfed10 /test/json.js
parente1594cde2c32e4ff48f6c4eff3d3d461743d74e1 (diff)
parent1bf68a5aa0703b5a1815cfe4ebb731b5fb6ed9d2 (diff)
downloadgitbook-34fc2831e0cf0fed01c71cec28d93472d87f455b.zip
gitbook-34fc2831e0cf0fed01c71cec28d93472d87f455b.tar.gz
gitbook-34fc2831e0cf0fed01c71cec28d93472d87f455b.tar.bz2
Merge branch 'version/2.0'
Diffstat (limited to 'test/json.js')
-rw-r--r--test/json.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/json.js b/test/json.js
new file mode 100644
index 0000000..e0ad14f
--- /dev/null
+++ b/test/json.js
@@ -0,0 +1,59 @@
+var path = require('path');
+var _ = require('lodash');
+var assert = require('assert');
+
+var fs = require("fs");
+
+describe('JSON generator', function () {
+ it('should correctly generate a book to json with glossary', function(done) {
+ testGeneration(books[0], "json", function(output) {
+ assert(fs.existsSync(path.join(output, "README.json")));
+
+ var readme = JSON.parse(fs.readFileSync(path.join(output, "README.json")));
+ assert(readme.sections[0].content.indexOf('class="glossary-term"') > 0);
+ }, done);
+ });
+
+ it('should correctly generate a book to json with sub folders', function(done) {
+ testGeneration(books[1], "json", function(output) {
+ assert(fs.existsSync(path.join(output, "README.json")));
+ assert(fs.existsSync(path.join(output, "intro.json")));
+ assert(fs.existsSync(path.join(output, "sub/test1.json")));
+
+ var test1 = JSON.parse(fs.readFileSync(path.join(output, "sub/test1.json")));
+ assert(test1.sections[0].content.indexOf("intro.html") > 0);
+ }, done);
+ });
+
+ it('should correctly generate a multilingual book to json', function(done) {
+ testGeneration(books[2], "json", function(output) {
+ assert(fs.existsSync(path.join(output, "README.json")));
+ assert(fs.existsSync(path.join(output, "en/README.json")));
+ assert(fs.existsSync(path.join(output, "fr/README.json")));
+ }, done);
+ });
+
+ it('should correctly generate an asciidoc book to json', function(done) {
+ testGeneration(books[3], "json", function(output) {
+ assert(fs.existsSync(path.join(output, "README.json")));
+ assert(fs.existsSync(path.join(output, "test.json")));
+ assert(fs.existsSync(path.join(output, "test1.json")));
+ assert(fs.existsSync(path.join(output, "test2.json")));
+ }, done);
+ });
+
+ it('should correctly generate a book with local inclusion', function(done) {
+ testGeneration(books[5], "json", function(output) {
+ var readme = JSON.parse(fs.readFileSync(path.join(output, "README.json")));
+ assert(readme.sections[0].content.indexOf('Hello World') > 0);
+ }, done);
+ });
+
+ it('should correctly generate a book with external inclusion', function(done) {
+ testGeneration(books[5], "json", function(output) {
+ var readme = JSON.parse(fs.readFileSync(path.join(output, "README.json")));
+ assert(readme.sections[0].content.indexOf('Git1:Hello from git') > 0);
+ assert(readme.sections[0].content.indexOf('Git2:First Hello. Hello from git') > 0);
+ }, done);
+ });
+});