mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-05 15:32:55 +02:00
Fix broken coverUrl for archived Epubs
When calling coverUrl for an archived epub the resolved promise contains undefined and not a string. Also the documentation everywhere is lying about coverUrl() returning a string whereas it actually returns a Promise that resolves to a string.
This commit is contained in:
parent
26075c2d49
commit
2f63b16276
4 changed files with 28 additions and 8 deletions
27
test/book.js
27
test/book.js
|
@ -1,11 +1,32 @@
|
|||
var assert = require('assert');
|
||||
|
||||
describe('Book', function() {
|
||||
|
||||
var Book = require('../src/book');
|
||||
|
||||
before(function(){
|
||||
|
||||
describe('Unarchived', function() {
|
||||
var book = new Book("/fixtures/alice/OPS/package.opf");
|
||||
it('should open a epub', async function() {
|
||||
await book.opened
|
||||
assert.equal(book.isOpen, true, "book is opened");
|
||||
assert.equal( book.url.toString(), "http://localhost:9876/fixtures/alice/OPS/package.opf", "book url is passed to new Book" );
|
||||
});
|
||||
it('should have a local coverUrl', async function() {
|
||||
assert.equal( await book.coverUrl(), "http://localhost:9876/fixtures/alice/OPS/images/cover_th.jpg", "cover url is available" );
|
||||
});
|
||||
});
|
||||
|
||||
describe('Archived epub', function() {
|
||||
var book = new Book("/fixtures/alice.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 blob coverUrl', async function() {
|
||||
let coverUrl = await book.coverUrl()
|
||||
assert( /^blob:http:\/\/localhost:9876\/[^\/]+$/.test(coverUrl), "cover url is available and a blob: url" );
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue