From 4460328bc1173f5d97fb4ff54edc041968486fce Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sat, 23 Jan 2010 15:54:58 -0800 Subject: lots of cleanup to get it ready for OS --- test/AngularTest.js | 15 ------- test/BinderTest.js | 105 +++++++++++++++++++++++++++-------------------- test/ControlBarTest.js | 2 - test/ExternalApiTest.js | 15 ------- test/JsonTest.js | 11 +++++ test/ScenarioSpec.js | 66 +++++++++++++++++++++++++++++ test/ScopeTest.js | 2 +- test/formsTest.js | 18 -------- test/testabilityPatch.js | 8 ++-- 9 files changed, 142 insertions(+), 100 deletions(-) delete mode 100644 test/ControlBarTest.js delete mode 100644 test/ExternalApiTest.js create mode 100644 test/ScenarioSpec.js delete mode 100644 test/formsTest.js (limited to 'test') diff --git a/test/AngularTest.js b/test/AngularTest.js index 9610ef76..a9146adf 100644 --- a/test/AngularTest.js +++ b/test/AngularTest.js @@ -1,20 +1,5 @@ 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'); diff --git a/test/BinderTest.js b/test/BinderTest.js index 0ffd2120..bbb3eb8f 100644 --- a/test/BinderTest.js +++ b/test/BinderTest.js @@ -5,10 +5,10 @@ function compile(content, initialScope, config) { config = config || {autoSubmit:true}; var scope = new Scope(initialScope, "ROOT"); h.data('scope', scope); - var binder = new Binder(h[0], new WidgetFactory(), new MockUrlWatcher(), config); + var binder = new Binder(h[0], new WidgetFactory(), new MockLocation(), config); var datastore = new DataStore(); scope.set("$datastore", datastore); - scope.set("$binder", binder); + scope.set("$updateView", _(binder.updateView).bind(binder)); scope.set("$anchor", binder.anchor); binder.entity(scope); binder.compile(); @@ -120,7 +120,7 @@ BinderTest.prototype.testChangingTextareaUpdatesModel = function(){ var form = html(''); var scope = new Scope({model:{}}); form.data('scope', scope); - var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation()); binder.compile(); binder.updateView(); assertEquals(scope.get('model').note, 'abc'); @@ -131,7 +131,7 @@ BinderTest.prototype.testChangingRadioUpdatesModel = function(){ ''); var scope = new Scope({model:{}}); form.data('scope', scope); - var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation()); binder.compile(); binder.updateView(); assertEquals(scope.get('model').price, 'A'); @@ -141,7 +141,7 @@ BinderTest.prototype.testChangingCheckboxUpdatesModel = function(){ var form = html(''); var scope = new Scope({model:{}}); form.data('scope', scope); - var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation()); binder.compile(); binder.updateView(); assertEquals('A', scope.get('model').price); @@ -157,7 +157,7 @@ BinderTest.prototype.testChangingSelectNonSelectedUpdatesModel = function(){ var form = html(''); var scope = new Scope({model:{}}); form.data('scope', scope); - var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation()); binder.compile(); binder.updateView(); assertEquals('A', scope.get('model').price); @@ -171,7 +171,7 @@ BinderTest.prototype.testChangingMultiselectUpdatesModel = function(){ ''); var scope = new Scope({Invoice:{}}); form.data('scope', scope); - var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation()); binder.compile(); binder.updateView(); assertJsonEquals(["A", "B"], scope.get('Invoice').options); @@ -181,7 +181,7 @@ BinderTest.prototype.testChangingSelectSelectedUpdatesModel = function(){ var form = html(''); var scope = new Scope({model:{}}); form.data('scope', scope); - var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation()); binder.compile(); binder.updateView(); assertEquals(scope.get('model').price, 'b'); @@ -210,7 +210,7 @@ BinderTest.prototype.testApplyTextBindings = function(){ var form = html('
x
'); var scope = new Scope({model:{a:123}}); form.data('scope', scope); - var binder = new Binder(form.get(0), null, new MockUrlWatcher()); + var binder = new Binder(form.get(0), null, new MockLocation()); binder.compile(); binder.updateView(); assertEquals('123', form.text()); @@ -287,7 +287,7 @@ BinderTest.prototype.testExistingAttrbindingIsAppended = function() { BinderTest.prototype.testAttributesAreEvaluated = function(){ var form = html(''); form.data('scope', new Scope({a:1, b:2})); - var binder = new Binder(form.get(0), null, new MockUrlWatcher()); + var binder = new Binder(form.get(0), null, new MockLocation()); binder.compile(); binder.updateView(); var a = form.find("a"); @@ -304,7 +304,7 @@ BinderTest.prototype.testInputsAreUpdated = function(){ '' + '' + ''); - var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation()); form.data('scope', new Scope({A:{text:"t1", textarea:"t2", radio:"r", checkbox:"c", select:"S"}})); binder.compile(); binder.updateView(); @@ -348,21 +348,27 @@ BinderTest.prototype.testButtonElementActionExecutesInScope = function(){ }; BinderTest.prototype.testParseEmptyAnchor = function(){ - var binder = new Binder(null, null, new MockUrlWatcher()); + var location = new MockLocation(); + var binder = new Binder(null, null, location); var anchor = binder.anchor; - binder.parseAnchor("a#x=1"); + location.url = "a#x=1"; + binder.parseAnchor(); assertEquals(1, binder.anchor.x); - binder.parseAnchor("a#"); + location.url = "a#"; + binder.parseAnchor(); assertTrue("old values did not get removed", !binder.anchor.x); assertTrue("anchor gor replaced", anchor === binder.anchor); assertEquals('undefined', typeof (anchor[""])); }; BinderTest.prototype.testParseAnchor = function(){ - var binder = new Binder(null, null, new MockUrlWatcher()); - binder.parseAnchor("a#x=1"); + var location = new MockLocation(); + var binder = new Binder(null, null, location); + location.url = "a#x=1"; + binder.parseAnchor(); assertEquals(binder.anchor.x, "1"); - binder.parseAnchor("a#a=b&c=%20&d"); + location.url = "a#a=b&c=%20&d"; + binder.parseAnchor(); assertEquals(binder.anchor.a, 'b'); assertEquals(binder.anchor.c, ' '); assertTrue(binder.anchor.d !== null); @@ -370,27 +376,27 @@ BinderTest.prototype.testParseAnchor = function(){ }; BinderTest.prototype.testWriteAnchor = function(){ - var binder = new Binder(null, null, new MockUrlWatcher()); - binder.urlWatcher.setUrl('a'); + var binder = new Binder(null, null, new MockLocation()); + binder.location.set('a'); binder.anchor.a = 'b'; binder.anchor.c = ' '; binder.anchor.d = true; binder.updateAnchor(); - assertEquals(binder.urlWatcher.getUrl(), "a#a=b&c=%20&d"); + assertEquals(binder.location.get(), "a#a=b&c=%20&d"); }; BinderTest.prototype.testWriteAnchorAsPartOfTheUpdateView = function(){ - var binder = new Binder(html("
")[0], null, new MockUrlWatcher()); - binder.urlWatcher.setUrl('a'); + var binder = new Binder(html("
")[0], null, new MockLocation()); + binder.location.set('a'); $(binder.doc).data('scope', new Scope()); binder.anchor.a = 'b'; binder.updateView(); - assertEquals(binder.urlWatcher.getUrl(), "a#a=b"); + assertEquals(binder.location.get(), "a#a=b"); }; BinderTest.prototype.testRepeaterUpdateBindings = function(){ var form = html(''); - var binder = new Binder(form.get(0), null, new MockUrlWatcher()); + var binder = new Binder(form.get(0), null, new MockLocation()); var items = [{a:"A"}, {a:"B"}]; form.data('scope', new Scope({model:{items:items}})); binder.compile(); @@ -423,7 +429,7 @@ BinderTest.prototype.testRepeaterUpdateBindings = function(){ BinderTest.prototype.testRepeaterContentDoesNotBind = function(){ var form = html(''); form.data('scope', new Scope({model:{items:[{a:"A"}]}})); - var binder = new Binder(form.get(0), null, new MockUrlWatcher()); + var binder = new Binder(form.get(0), null, new MockLocation()); binder.compile(); binder.updateView(); assertEquals('