summaryrefslogtreecommitdiffstats
path: root/test/helper.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/helper.js')
-rw-r--r--test/helper.js78
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();
-});