diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-03-23 23:23:25 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-03-23 23:23:25 +0100 |
commit | 17b546181c0af8f3086fdf1b38b39a2bee7155e4 (patch) | |
tree | 957ac528f3988d5476b232e8902989bfc5109ab2 | |
parent | 2d1aa15af8ee73f7179e323493ab4f6c40f6ac57 (diff) | |
download | gitbook-17b546181c0af8f3086fdf1b38b39a2bee7155e4.zip gitbook-17b546181c0af8f3086fdf1b38b39a2bee7155e4.tar.gz gitbook-17b546181c0af8f3086fdf1b38b39a2bee7155e4.tar.bz2 |
Fix cleanup after tests
-rw-r--r-- | test/books/basic/_book/README.json | 31 | ||||
-rw-r--r-- | test/helper.js | 32 | ||||
-rw-r--r-- | test/json.js | 1 |
3 files changed, 15 insertions, 49 deletions
diff --git a/test/books/basic/_book/README.json b/test/books/basic/_book/README.json deleted file mode 100644 index 13dae6b..0000000 --- a/test/books/basic/_book/README.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "progress": { - "prevPercent": 0, - "percent": 0, - "chapters": [ - { - "index": 0, - "title": "", - "level": "0", - "path": "README.md", - "percent": 0, - "done": true - } - ], - "current": { - "index": 0, - "title": "", - "level": "0", - "path": "README.md", - "percent": 0, - "done": true - } - }, - "sections": [ - { - "type": "normal", - "content": "<h1 id=\"readme\">Readme</h1>\n" - } - ], - "langs": [] -}
\ No newline at end of file diff --git a/test/helper.js b/test/helper.js index dfaaeb4..5e65441 100644 --- a/test/helper.js +++ b/test/helper.js @@ -15,15 +15,25 @@ var TMPDIR = os.tmpdir(); // Generate and return a book function generateBook(bookId, test) { + return parseBook(bookId, test) + .then(function(book) { + return book.generate(test) + .thenResolve(book); + }); +} + +// Generate and return a book +function parseBook(bookId, test) { BOOKS[bookId] = BOOKS[bookId] || {}; if (BOOKS[bookId][test]) return Q(BOOKS[bookId][test]); BOOKS[bookId][test] = new Book(path.resolve(__dirname, "books", bookId), { logLevel: LOG_LEVELS.DISABLED, - output: path.resolve(TMPDIR, bookId+"-"+test) + config: { + output: path.resolve(TMPDIR, bookId+"-"+test) + } }); - console.log("gen"); return BOOKS[bookId][test].parse() .then(function() { return BOOKS[bookId][test].generate(test); @@ -33,19 +43,6 @@ function generateBook(bookId, test) { }); } -// Generate and return a book -function parseBook(bookId, test) { - BOOKS[bookId] = BOOKS[bookId] || {}; - if (BOOKS[bookId][test]) return Q(BOOKS[book][test]); - - BOOKS[bookId] = new Book(path.resolve(__dirname, "books", bookId), { - logLevel: LOG_LEVELS.DISABLED, - output: path.resolve(TMPDIR, bookId+"-"+test) - }); - - return BOOKS[bookId].parse(); -} - global.books = { parse: parseBook, @@ -54,17 +51,16 @@ global.books = { // Cleanup all tests after(function() { - console.log("cleanup!"); return _.chain(BOOKS) .map(function(types, bookId) { return _.values(types); }) + .flatten() .reduce(function(prev, book) { return prev.then(function() { - console.log("cleanup", book.options.output); return fsUtil.remove(book.options.output); }) - }) + }, Q()) .value(); }); diff --git a/test/json.js b/test/json.js index 82966a9..db4814b 100644 --- a/test/json.js +++ b/test/json.js @@ -3,6 +3,7 @@ describe('JSON generator', function () { it('should correctly generate a basic book to json', function() { return books.generate("basic", "json") .then(function(book) { + }); }); }); |