diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-22 17:06:33 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-22 17:06:33 +0100 |
commit | be651f0138664b35cae9a03a5c521dc138e48f2b (patch) | |
tree | a3b781681aa6948cca8d342b84aa7f1a7e995f7e /test/json.js | |
parent | 974819bafb858ab4ed3e4a21e4cb4536234f7690 (diff) | |
download | gitbook-be651f0138664b35cae9a03a5c521dc138e48f2b.zip gitbook-be651f0138664b35cae9a03a5c521dc138e48f2b.tar.gz gitbook-be651f0138664b35cae9a03a5c521dc138e48f2b.tar.bz2 |
Separate test for geenration
Diffstat (limited to 'test/json.js')
-rw-r--r-- | test/json.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/json.js b/test/json.js new file mode 100644 index 0000000..cc01700 --- /dev/null +++ b/test/json.js @@ -0,0 +1,36 @@ +var path = require('path'); +var _ = require('lodash'); +var assert = require('assert'); + +var fs = require("fs"); +var fsUtil = require("../lib/utils/fs"); + +describe('JSON generator', function () { + it('should correctly generate a book to json', 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); + }); +}); |