Merged changes upstream
[bookreader.git] / BookReaderIA / test / unit / JSLocate.js
1 // Tests for BookReaderJSLocate.php
2
3 // $$$ TODO -- make the test host configurable/automagic
4
5 module("JSLocate");
6
7 testHost = 'http://www-testflip.archive.org';
8
9 // Returns locator URL for the given id
10 function jsLocateURL(bookId) {
11     return testHost + '/bookreader/BookReaderJSLocate.php?id=' + bookId;
12 }
13
14 // Set up dummy BookReader class for JSLocate
15 function BookReader() {
16 };
17
18 BookReader.prototype.init = function() {
19     return true;
20 };
21
22 asyncTest("JSLocate for notesonsubmarine00grea", function() {
23     expect(1);
24     $.getScript( jsLocateURL('notesonsubmarine00grea'),
25         function(data, textStatus) {
26             equals(window.br.titleLeaf, 5, 'Metadata loaded.  See https://bugs.launchpad.net/bookreader/+bug/517424. Title leaf');
27             start();
28         }
29     );
30 });
31
32 asyncTest("JSLocate for photographingclo00carprich", function() {
33     expect(1);
34     $.getScript( jsLocateURL('photographingclo00carprich'),
35         function(data, textStatus) {
36             equals(window.br.bookTitle, 'Photographing clouds from an airplane',  'Title of book');
37             start();
38         }
39     );
40 });
41
42 asyncTest("JSLocate for salmoncookbookho00panaiala", function() {
43     expect(1);
44     $.getScript( jsLocateURL('salmoncookbookho00panaiala'),
45         function(data, textStatus) {
46             equals(window.br.numLeafs, 40,  'Number of pages');
47             start();
48         }
49     );
50 });