Test ebook generation instead of pdf output

This commit is contained in:
Samy Pessé
2015-01-23 14:10:45 +01:00
parent ccd2f6ecdc
commit df16f3d90d
4 changed files with 20 additions and 17 deletions
+4 -2
View File
@@ -12,10 +12,10 @@ var Generator = function(book, format) {
BaseGenerator.apply(this, arguments);
// eBook format
this.ebookFormat = format || "pdf";
this.ebookFormat = format;
// Styles to use
this.styles = ["ebook", this.ebookFormat];
this.styles = _.compact(["ebook", this.ebookFormat]);
};
util.inherits(Generator, BaseGenerator);
@@ -47,6 +47,8 @@ Generator.prototype.finish = function() {
return that.writeSummary();
})
.then(function() {
if (!that.ebookFormat) return Q();
var d = Q.defer();
if (!that.options.cover && fs.existsSync(path.join(that.options.output, "cover.jpg"))) {
+1
View File
@@ -4,6 +4,7 @@ var EbookGenerator = require("./ebook");
module.exports = {
json: require("./json"),
website: require("./website"),
ebook: EbookGenerator,
pdf: _.partialRight(EbookGenerator, "pdf"),
mobi: _.partialRight(EbookGenerator, "mobi"),
epub: _.partialRight(EbookGenerator, "epub")
+15
View File
@@ -0,0 +1,15 @@
var path = require('path');
var _ = require('lodash');
var assert = require('assert');
var fs = require("fs");
var fsUtil = require("../lib/utils/fs");
describe('eBook Generator', function () {
it('should correctly generate ebook pages', function(done) {
testGeneration(books[1], "ebook", function(output) {
assert(fs.existsSync(path.join(output, "SUMMARY.html")));
}, done);
});
});
-15
View File
@@ -1,15 +0,0 @@
var path = require('path');
var _ = require('lodash');
var assert = require('assert');
var fs = require("fs");
var fsUtil = require("../lib/utils/fs");
describe('PDF Generator', function () {
it('should correctly generate a pdf', function(done) {
testGeneration(books[1], "pdf", function(output) {
assert(fs.existsSync(path.join(output, "book.pdf")));
}, done);
});
});