diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-26 09:41:26 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-26 09:41:26 +0100 |
commit | d3d64f636c859f7f01a64f7774cf70bd8ccdc562 (patch) | |
tree | 4f7731f37c3a793d187b0ab1cd77680e69534c6c /test/helper.js | |
parent | 4cb9cbb5ae3aa8f9211ffa3ac5e3d34232c0ca4f (diff) | |
parent | eef072693b17526347c37b66078a5059c71caa31 (diff) | |
download | gitbook-d3d64f636c859f7f01a64f7774cf70bd8ccdc562.zip gitbook-d3d64f636c859f7f01a64f7774cf70bd8ccdc562.tar.gz gitbook-d3d64f636c859f7f01a64f7774cf70bd8ccdc562.tar.bz2 |
Merge pull request #1109 from GitbookIO/3.0.0
Version 3.0.0
Diffstat (limited to 'test/helper.js')
-rw-r--r-- | test/helper.js | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/test/helper.js b/test/helper.js deleted file mode 100644 index bbe82de..0000000 --- a/test/helper.js +++ /dev/null @@ -1,78 +0,0 @@ -var os = require('os'); -var path = require('path'); -var Q = require('q'); -var _ = require('lodash'); - -var fsUtil = require('../lib/utils/fs'); -var Book = require('../').Book; -var LOG_LEVELS = require('../').LOG_LEVELS; - -require('./assertions'); - - -var BOOKS = {}; -var TMPDIR = os.tmpdir(); - - -// Generate and return a book -function generateBook(bookId, test, opts) { - opts = _.defaults(opts || {}, { - prepare: function() {} - }); - - return parseBook(bookId, test, opts) - .then(function(book) { - - return Q(opts.prepare(book)) - .then(function() { - return book.generate(test); - }) - .thenResolve(book); - }); -} - -// Generate and return a book -function parseBook(bookId, test, opts) { - opts = _.defaults(opts || {}, { - testId: '' - }); - - test = test || 'website'; - var testId = [test, opts.testId].join('-'); - - BOOKS[bookId] = BOOKS[bookId] || {}; - if (BOOKS[bookId][testId]) return Q(BOOKS[bookId][testId]); - - BOOKS[bookId][testId] = new Book(path.resolve(__dirname, 'books', bookId), { - logLevel: LOG_LEVELS.DISABLED, - config: { - output: path.resolve(TMPDIR, bookId+'-'+testId) - } - }); - - return BOOKS[bookId][testId].parse() - .then(function() { - return BOOKS[bookId][testId]; - }); -} - - -global.books = { - parse: parseBook, - generate: generateBook -}; - -// Cleanup all tests -after(function() { - return _.chain(BOOKS) - .map(function(types) { - return _.values(types); - }) - .flatten() - .reduce(function(prev, book) { - return prev.then(function() { - return fsUtil.remove(book.options.output); - }); - }, Q()) - .value(); -}); |