module("Preview");
-function Book(identifier, previewWidth, coverWidth, titleWidth) {
+function Book(identifier, previewWidth, coverWidth, titleWidth, imageSize, bookId) {
this.identifier = identifier;
this.previewWidth = previewWidth;
this.coverWidth = coverWidth;
this.titleWidth = titleWidth;
+ if (bookId === undefined) {
+ bookId = identifier;
+ }
+ this.bookId = bookId;
}
var books = [
- new Book('coloritsapplicat00andriala', 1974, 2346, 1974),
- new Book('lietuvostsrmoksl50liet', 1887, 1747, 1887),
- new Book('oldtestamentrevi02slsn', 2019, 2371, 2019)
+ // Old books using title page as cover (ignoring marked cover)
+ new Book('coloritsapplicat00andriala', 1974, 1974, 1974),
+ new Book('lietuvostsrmoksl50liet', 1887, 1887, 1887),
+ new Book('oldtestamentrevi02slsn', 2019, 2019, 2019),
+
+ // Protected book with marked cover returned as cover
+ new Book('joyofsoaringtrai00conw', 2571, 2571, 2419)
+
];
for (index in books) {
var book = books[i];
var identifier = book.identifier;
- var pageURI = previewURL(identifier, identifier, 'preview');
+ var pageURI = previewURL(identifier, book.bookId, 'preview');
var img = new Image();
$(img).bind( 'load error', function(eventObj) {
equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
var book = books[i];
var identifier = book.identifier;
- var pageURI = previewURL(identifier, identifier, 'cover');
+ var pageURI = previewURL(identifier, book.bookId, 'cover');
var img = new Image();
$(img).bind( 'load error', function(eventObj) {
equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
var book = books[i];
var identifier = book.identifier;
- var pageURI = previewURL(identifier, identifier, 'title');
+ var pageURI = previewURL(identifier, book.bookId, 'title');
var img = new Image();
$(img).bind( 'load error', function(eventObj) {
equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
img = null;
});
})();
-}
\ No newline at end of file
+}
+
+// Multi-book item
+var identifier = 'SubBookTest';
+asyncTest("Load title for book without title specified " + identifier, function() {
+ expect(1);
+
+ var pageURI = previewURL(identifier, identifier, 'title');
+ var img = new Image();
+ $(img).bind( 'load error', function(eventObj) {
+ equals(eventObj.type, 'error', 'Load image (' + pageURI + '). Event handler called');
+ start();
+ })
+ .attr('src', pageURI);
+
+ img = null;
+});
+
+var subPrefix = 'subdir/subsubdir/book3/Rfp008011ResponseInternetArchive-without-resume';
+asyncTest("Load preview for book in sub-dir " + identifier + '/' + subPrefix, function() {
+ expect(2);
+
+ var pageURI = previewURL(identifier, subPrefix, 'title');
+ var img = new Image();
+ $(img).bind( 'load error', function(eventObj) {
+ equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
+ equals(this.width, 5100, 'Preview image width');
+ start();
+ })
+ .attr('src', pageURI);
+
+ img = null;
+});