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 | |
parent | 974819bafb858ab4ed3e4a21e4cb4536234f7690 (diff) | |
download | gitbook-be651f0138664b35cae9a03a5c521dc138e48f2b.zip gitbook-be651f0138664b35cae9a03a5c521dc138e48f2b.tar.gz gitbook-be651f0138664b35cae9a03a5c521dc138e48f2b.tar.bz2 |
Separate test for geenration
-rw-r--r-- | test/helper.js | 15 | ||||
-rw-r--r-- | test/json.js (renamed from test/generation.js) | 32 | ||||
-rw-r--r-- | test/website.js | 24 |
3 files changed, 40 insertions, 31 deletions
diff --git a/test/helper.js b/test/helper.js index 27d5f01..6e167ea 100644 --- a/test/helper.js +++ b/test/helper.js @@ -14,6 +14,21 @@ global.qdone = function qdone(promise, done) { }).done(); }; +// Test generation of a book +global.testGeneration = function(book, type, func, done) { + var OUTPUT_PATH = book.options.output; + + qdone( + book.generate(type) + .then(function() { + func(OUTPUT_PATH); + }) + .fin(function() { + return fsUtil.remove(OUTPUT_PATH); + }), + done); +}; + // Books for testings global.books = []; diff --git a/test/generation.js b/test/json.js index a8f9c69..cc01700 100644 --- a/test/generation.js +++ b/test/json.js @@ -5,22 +5,7 @@ var assert = require('assert'); var fs = require("fs"); var fsUtil = require("../lib/utils/fs"); -var testGeneration = function(book, type, func, done) { - var OUTPUT_PATH = book.options.output; - - qdone( - book.generate(type) - .then(function() { - func(OUTPUT_PATH); - }) - .fin(function() { - return fsUtil.remove(OUTPUT_PATH); - }), - done); -}; - - -describe('Book generation', function () { +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"))); @@ -48,19 +33,4 @@ describe('Book generation', function () { assert(fs.existsSync(path.join(output, "test2.json"))); }, done); }); - - it('should correctly generate a book to website', function(done) { - testGeneration(books[1], "site", function(output) { - assert(fs.existsSync(path.join(output, "index.html"))); - }, done); - }); - - it('should correctly include styles in website', function(done) { - testGeneration(books[0], "site", function(output) { - assert(fs.existsSync(path.join(output, "styles/website.css"))); - - var INDEX = fs.readFileSync(path.join(output, "index.html")).toString(); - assert(INDEX.indexOf("styles/website.css") > 0); - }, done); - }); }); diff --git a/test/website.js b/test/website.js new file mode 100644 index 0000000..7efcec1 --- /dev/null +++ b/test/website.js @@ -0,0 +1,24 @@ +var path = require('path'); +var _ = require('lodash'); +var assert = require('assert'); + +var fs = require("fs"); +var fsUtil = require("../lib/utils/fs"); + + +describe('Website Generator', function () { + it('should correctly generate a book to website', function(done) { + testGeneration(books[1], "site", function(output) { + assert(fs.existsSync(path.join(output, "index.html"))); + }, done); + }); + + it('should correctly include styles in website', function(done) { + testGeneration(books[0], "site", function(output) { + assert(fs.existsSync(path.join(output, "styles/website.css"))); + + var INDEX = fs.readFileSync(path.join(output, "index.html")).toString(); + assert(INDEX.indexOf("styles/website.css") > 0); + }, done); + }); +}); |