Additional JSLocate unit tests
authorMichael Ang <testflip@home.us.archive.org>
Fri, 12 Feb 2010 19:57:56 +0000 (19:57 +0000)
committerMichael Ang <testflip@home.us.archive.org>
Fri, 12 Feb 2010 19:57:56 +0000 (19:57 +0000)
BookReaderIA/test/unit/JSLocate.js

index 2d814bf..17136c7 100644 (file)
@@ -6,6 +6,11 @@ module("JSLocate");
 
 testHost = 'http://www-testflip.archive.org';
 
+// Returns locator URL for the given id
+function jsLocateURL(bookId) {
+    return testHost + '/bookreader/BookReaderJSLocate.php?id=' + bookId;
+}
+
 // Set up dummy BookReader class for JSLocate
 function BookReader() {
 };
@@ -16,11 +21,30 @@ BookReader.prototype.init = function() {
 
 asyncTest("JSLocate for notesonsubmarine00grea", function() {
     expect(1);
-    $.getScript(testHost + '/bookreader/BookReaderJSLocate.php?id=amonographonmec00buregoog',
+    $.getScript( jsLocateURL('notesonsubmarine00grea'),
+        function(data, textStatus) {
+            equals(window.br.titleLeaf, 5, 'Metadata loaded.  See https://bugs.launchpad.net/bookreader/+bug/517424. Title leaf');
+            start();
+        }
+    );
+});
+
+asyncTest("JSLocate for photographingclo00carprich", function() {
+    expect(1);
+    $.getScript( jsLocateURL('photographingclo00carprich'),
         function(data, textStatus) {
-            equals(13, window.br.titleLeaf, 'br object should exist with title leaf 13. See https://bugs.launchpad.net/bookreader/+bug/517424');
+            equals(window.br.bookTitle, 'Photographing clouds from an airplane',  'Title of book');
             start();
         }
     );
 });
 
+asyncTest("JSLocate for salmoncookbookho00panaiala", function() {
+    expect(1);
+    $.getScript( jsLocateURL('salmoncookbookho00panaiala'),
+        function(data, textStatus) {
+            equals(window.br.numLeafs, 40,  'Number of pages');
+            start();
+        }
+    );
+});