diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/generation.js | 37 | ||||
-rw-r--r-- | test/parsing.js | 4 |
2 files changed, 25 insertions, 16 deletions
diff --git a/test/generation.js b/test/generation.js index 6bfb095..b043885 100644 --- a/test/generation.js +++ b/test/generation.js @@ -2,26 +2,35 @@ var path = require('path'); var _ = require('lodash'); var assert = require('assert'); -var fs = require('../lib/utils/fs'); +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 () { it('should correctly generate a book to json', function(done) { - var OUTPUT_PATH = book1.options.output; - - qdone( - book1.generate("json") - .fin(function() { - return fs.remove(OUTPUT_PATH); - }), done); + testGeneration(book1, "json", function(output) { + assert(!fs.existsSync(path.join(output, "README.json"))); + assert(fs.existsSync(path.join(output, "intro.json"))) + }, done); }); it('should correctly generate a multilingual book to json', function(done) { - var OUTPUT_PATH = book2.options.output; + testGeneration(book2, "json", function(output) { - qdone( - book2.generate("json") - .fin(function() { - return fs.remove(OUTPUT_PATH); - }), done); + }, done); }); }); diff --git a/test/parsing.js b/test/parsing.js index 636b574..bde8be3 100644 --- a/test/parsing.js +++ b/test/parsing.js @@ -31,8 +31,8 @@ describe('Book parsing', function () { it('should correctly parse files', function() { var FILES = book1.files; - assert.equal(FILES.length, 4); - assert.equal(_.difference(FILES, [ 'GLOSSARY.md', 'README.md', 'SUMMARY.md', 'intro.md' ]).length, 0); + assert.equal(FILES.length, 2); + assert.equal(_.difference(FILES, [ 'intro.md', 'README.md' ]).length, 0); }); it('should correctly parse the languages', function() { |