From: Michael Ang Date: Tue, 3 Aug 2010 00:34:23 +0000 (+0000) Subject: Update unit tests to autodetect testing host X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;ds=sidebyside;h=520a541a4743b74a4e1a2554ebe0c45703816ec8;p=bookreader.git Update unit tests to autodetect testing host --- diff --git a/BookReaderIA/test/index.html b/BookReaderIA/test/index.html index 51f5b8a..851c779 100644 --- a/BookReaderIA/test/index.html +++ b/BookReaderIA/test/index.html @@ -11,6 +11,13 @@ + diff --git a/BookReaderIA/test/unit/Common.js b/BookReaderIA/test/unit/Common.js index 8a860d7..98ddb30 100644 --- a/BookReaderIA/test/unit/Common.js +++ b/BookReaderIA/test/unit/Common.js @@ -1,9 +1,27 @@ // Defines common variables for testing -// $$$ TODO make test host auto-magic -common = { - testHost: 'http://www-testflip.archive.org' - //testHost: 'http://www-mang.archive.org' +// What host to use for testing +function testHost() { + // Autodetect if running from a home directory, or use live site + var user = null; + var patterns = [ new RegExp('.*?/~(.*?)/'), new RegExp('www-(.*?)\\.') ] + for (index in patterns) { + var match = patterns[index].exec(document.location.href); + if (match) { + user = match[1]; + break; + } + } + + if (user) { + return 'http://www-' + user + '.archive.org'; + } + + return 'http://www.archive.org'; // live site +} + +var common = { + testHost: testHost(), } // Set up dummy BookReader class for JSLocate diff --git a/BookReaderIA/test/unit/JSLocate.js b/BookReaderIA/test/unit/JSLocate.js index 148b19f..f98c1e4 100644 --- a/BookReaderIA/test/unit/JSLocate.js +++ b/BookReaderIA/test/unit/JSLocate.js @@ -4,6 +4,9 @@ module("JSLocate"); +// $$$ locate will fail when called from the same domain since the browser will not honour the +// redirect to the datanode + asyncTest("JSLocate for notesonsubmarine00grea", function() { expect(1); $.getScript( jsLocateURL('notesonsubmarine00grea'),