From 595b4ea097bcb512173b6d4a12924ea1a3d70ecd Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 18 Jan 2010 10:47:03 -0800 Subject: checkpoint for integration with angular --- test/AngularTest.js | 60 +++++++++++++++++++++++++++++++++++++++++ test/LoaderTest.js | 70 ------------------------------------------------ test/testabilityPatch.js | 2 +- 3 files changed, 61 insertions(+), 71 deletions(-) create mode 100644 test/AngularTest.js delete mode 100644 test/LoaderTest.js (limited to 'test') diff --git a/test/AngularTest.js b/test/AngularTest.js new file mode 100644 index 00000000..9610ef76 --- /dev/null +++ b/test/AngularTest.js @@ -0,0 +1,60 @@ +AngularTest = TestCase('AngularTest'); + +AngularTest.prototype.testDefaultDatabasePathFromSubdomain = function() { + var loader = new Angular(null, null, {server:"http://account.getangular.com", database:"database"}); + loader.computeConfiguration(); + assertEquals("database", loader.config.database); + + loader = new Angular(null, null, {server:"http://account.getangular.com"}); + loader.computeConfiguration(); + assertEquals("account", loader.config.database); + + loader = new Angular(null, null, {server:"https://account.getangular.com"}); + loader.computeConfiguration(); + assertEquals("account", loader.config.database); +}; + + + +UrlWatcherTest = TestCase('UrlWatcherTest'); + +UrlWatcherTest.prototype.testUrlWatcher = function () { + expectAsserts(2); + var location = {href:"http://server", hash:""}; + var watcher = new UrlWatcher(location); + watcher.delay = 1; + watcher.listener = function(url){ + assertEquals('http://getangular.test', url); + }; + watcher.setTimeout = function(fn, delay){ + assertEquals(1, delay); + location.href = "http://getangular.test"; + watcher.setTimeout = function(fn, delay) { + }; + fn(); + }; + watcher.watch(); +}; + +UrlWatcherTest.prototype.testItShouldFireOnUpdateEventWhenSpecialURLSet = function(){ + expectAsserts(2); + var location = {href:"http://server", hash:"#$iframe_notify=1234"}; + var watcher = new UrlWatcher(location); + angular.callbacks._iframe_notify_1234 = function () { + assertEquals("undefined", typeof angularCallbacks._iframe_notify_1234); + assertEquals("http://server2#", location.href); + }; + watcher.delay = 1; + watcher.expectedUrl = "http://server2"; + watcher.setTimeout = function(fn, delay){ + watcher.setTimeout = function(fn, delay) {}; + fn(); + }; + watcher.watch(); +}; + +FunctionTest = TestCase("FunctionTest"); + +FunctionTest.prototype.testEscapeHtml = function () { + assertEquals("<div>&amp;</div>", escapeHtml('
&
')); +}; \ No newline at end of file diff --git a/test/LoaderTest.js b/test/LoaderTest.js deleted file mode 100644 index a474c8a4..00000000 --- a/test/LoaderTest.js +++ /dev/null @@ -1,70 +0,0 @@ -LoaderTest = TestCase('LoaderTest'); - -LoaderTest.prototype.testLoadCss = function(){ - if ($.browser.safari) return; - var head = jQuery('')[0]; - var loader = new Loader(document, head, {}); - var log = ''; - loader.config.server = 'http://'; - loader.loadCss('x'); - assertEquals($(head).find('link').attr('href'), 'http://x'); -}; - -LoaderTest.prototype.testDefaultDatabasePathFromSubdomain = function() { - var loader = new Loader(null, null, {server:"http://account.getangular.com", database:"database"}); - loader.computeConfiguration(); - assertEquals("database", loader.config.database); - - loader = new Loader(null, null, {server:"http://account.getangular.com"}); - loader.computeConfiguration(); - assertEquals("account", loader.config.database); - - loader = new Loader(null, null, {server:"https://account.getangular.com"}); - loader.computeConfiguration(); - assertEquals("account", loader.config.database); -}; - - - -UrlWatcherTest = TestCase('UrlWatcherTest'); - -UrlWatcherTest.prototype.testUrlWatcher = function () { - expectAsserts(2); - var location = {href:"http://server", hash:""}; - var watcher = new UrlWatcher(location); - watcher.delay = 1; - watcher.listener = function(url){ - assertEquals('http://getangular.test', url); - }; - watcher.setTimeout = function(fn, delay){ - assertEquals(1, delay); - location.href = "http://getangular.test"; - watcher.setTimeout = function(fn, delay) { - }; - fn(); - }; - watcher.watch(); -}; - -UrlWatcherTest.prototype.testItShouldFireOnUpdateEventWhenSpecialURLSet = function(){ - expectAsserts(2); - var location = {href:"http://server", hash:"#$iframe_notify=1234"}; - var watcher = new UrlWatcher(location); - angular.callbacks._iframe_notify_1234 = function () { - assertEquals("undefined", typeof angularCallbacks._iframe_notify_1234); - assertEquals("http://server2#", location.href); - }; - watcher.delay = 1; - watcher.expectedUrl = "http://server2"; - watcher.setTimeout = function(fn, delay){ - watcher.setTimeout = function(fn, delay) {}; - fn(); - }; - watcher.watch(); -}; - -FunctionTest = TestCase("FunctionTest"); - -FunctionTest.prototype.testEscapeHtml = function () { - assertEquals("<div>&amp;</div>", escapeHtml('
&
')); -}; \ No newline at end of file diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index dde21846..78ffd380 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -96,7 +96,7 @@ function decode64(base64){ return fromJson(Base64.decode(base64)); } -Loader.prototype.configureJQueryPlugins(); +Angular.prototype.configureJQueryPlugins(); function assertHidden(node) { var display = node.css('display'); -- cgit v1.2.3