diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-03-23 23:48:46 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-03-23 23:48:46 +0100 |
commit | ec8d1d8fc919f1a2918ccc5abf04033139f2cb53 (patch) | |
tree | 05e65c8920ade0546ebc4bb5d907705853a7a851 /test/json.js | |
parent | 868a3186dd40e57ec1c38174be1db28dfd4c85c4 (diff) | |
download | gitbook-ec8d1d8fc919f1a2918ccc5abf04033139f2cb53.zip gitbook-ec8d1d8fc919f1a2918ccc5abf04033139f2cb53.tar.gz gitbook-ec8d1d8fc919f1a2918ccc5abf04033139f2cb53.tar.bz2 |
Improve test for json format
Diffstat (limited to 'test/json.js')
-rw-r--r-- | test/json.js | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/test/json.js b/test/json.js index 7bebd4c..3ee2066 100644 --- a/test/json.js +++ b/test/json.js @@ -1,11 +1,46 @@ +var fs = require('fs'); +var path = require('path'); describe('JSON generator', function () { describe('Basic Book', function() { - it('should correctly output a README.json', function() { + var book; + + before(function() { return books.generate("basic", "json") - .then(function(book) { - book.should.have.file("README.json"); + .then(function(_book) { + book = _book; }); }); + + it('should correctly output a README.json', function() { + book.should.have.file("README.json"); + }); + + it('should output a valid json', function() { + book.should.have.jsonfile("README.json"); + }); + + describe('Page Format', function() { + var page; + + before(function() { + page = JSON.parse( + fs.readFileSync( + path.join(book.options.output, "README.json"), + { encoding: "utf-8" } + ) + ); + }); + + it('should contains valid section', function() { + page.should.have.property("sections").with.lengthOf(1); + page.sections[0].should.have.property("content").which.is.a.String; + page.sections[0].should.have.property("type").which.is.a.String.which.equal("normal"); + }); + + it('should contains no languages', function() { + page.should.have.property("langs").with.lengthOf(0); + }); + }); }); }); |