mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
Fix opening an ArrayBuffer without options
Opening an archived Epub in an ArrayBuffer without passing in options will never resolve its `book.opened` Promise.
This commit is contained in:
parent
0e3104461d
commit
2732e172cd
2 changed files with 23 additions and 1 deletions
|
@ -52,7 +52,8 @@ class Book {
|
|||
// Allow passing just options to the Book
|
||||
if (typeof(options) === "undefined" &&
|
||||
typeof(url) !== "string" &&
|
||||
url instanceof Blob === false) {
|
||||
url instanceof Blob === false &&
|
||||
url instanceof ArrayBuffer === false) {
|
||||
options = url;
|
||||
url = undefined;
|
||||
}
|
||||
|
|
21
test/book.js
21
test/book.js
|
@ -29,4 +29,25 @@ describe('Book', function() {
|
|||
assert( /^blob:http:\/\/localhost:9876\/[^\/]+$/.test(coverUrl), "cover url is available and a blob: url" );
|
||||
});
|
||||
});
|
||||
|
||||
describe('Archived epub in array buffer without options', function() {
|
||||
let book;
|
||||
|
||||
before(async function() {
|
||||
const response = await fetch("/fixtures/alice.epub");
|
||||
const buffer = await response.arrayBuffer()
|
||||
book = new Book(buffer)
|
||||
})
|
||||
|
||||
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