diff --git a/src/book.js b/src/book.js index 0fcc30b..c75c58d 100644 --- a/src/book.js +++ b/src/book.js @@ -665,8 +665,8 @@ class Book { */ coverUrl() { var retrieved = this.loaded.cover. - then((url) => { - if(this.archived) { + then(() => { + if(this.archived && this.cover) { return this.archive.createUrl(this.cover); }else{ return this.cover; diff --git a/test/book.js b/test/book.js index a6c8539..b839f56 100644 --- a/test/book.js +++ b/test/book.js @@ -50,4 +50,18 @@ describe('Book', function() { assert( /^blob:http:\/\/localhost:9876\/[^\/]+$/.test(coverUrl), "cover url is available and a blob: url" ); }); }); + + describe('Archived epub without cover', function() { + var book = new Book("/fixtures/alice_without_cover.epub"); + + it('should open a archived epub', async function() { + await book.opened + assert.equal(book.isOpen, true, "book is opened"); + assert(book.archive, "book is unarchived"); + }); + it('should have a empty coverUrl', async function() { + let coverUrl = await book.coverUrl() + assert.equal(coverUrl, undefined, "cover url should be undefined" ); + }); + }); }); diff --git a/test/fixtures/alice_without_cover.epub b/test/fixtures/alice_without_cover.epub new file mode 100644 index 0000000..b215b2a Binary files /dev/null and b/test/fixtures/alice_without_cover.epub differ