Update preview image generation. Update unit tests.
[bookreader.git] / BookReaderIA / test / unit / Preview.js
1 // Tests for BookReaderPreview.php
2
3 // Depends on common.js
4
5 module("Preview");
6
7 var identifiers = [
8     'coloritsapplicat00andriala',
9     'lietuvostsrmoksl50liet',
10     'oldtestamentrevi02slsn',
11     'bokeofsaintalban00bernuoft'
12 ];
13
14 for (index in identifiers) {
15     var identifier = identifiers[index];
16     asyncTest("Load preview for " + identifier, function() {
17         expect(1);
18         
19         var pageURI = previewURL(identifier, identifier, 'preview');
20         var img = new Image();
21         $(img).bind( 'load error', function(eventObj) {
22             equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
23             start();
24         })
25         .attr('src', pageURI);
26         
27         img = null;
28     });
29     
30     asyncTest("Load cover for " + identifier, function() {
31         expect(1);
32         
33         var pageURI = previewURL(identifier, identifier, 'cover');
34         var img = new Image();
35         $(img).bind( 'load error', function(eventObj) {
36             equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
37             start();
38         })
39         .attr('src', pageURI);
40         
41         img = null;
42     });
43     
44     asyncTest("Load title for " + identifier, function() {
45         expect(1);
46         
47         var pageURI = previewURL(identifier, identifier, 'title');
48         var img = new Image();
49         $(img).bind( 'load error', function(eventObj) {
50             equals(eventObj.type, 'load', 'Load image (' + pageURI + '). Event handler called');
51             start();
52         })
53         .attr('src', pageURI);
54         
55         img = null;
56     });
57
58
59 }