diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/BinderTest.js | 209 | ||||
| -rw-r--r-- | test/ConsoleTest.js | 9 | ||||
| -rw-r--r-- | test/DataStoreTest.js | 96 | ||||
| -rw-r--r-- | test/EntityDeclarationTest.js | 8 | ||||
| -rw-r--r-- | test/FileControllerTest.js | 24 | ||||
| -rw-r--r-- | test/FiltersTest.js | 16 | ||||
| -rw-r--r-- | test/JsonTest.js | 54 | ||||
| -rw-r--r-- | test/LoaderTest.js | 18 | ||||
| -rw-r--r-- | test/ModelTest.js | 12 | ||||
| -rw-r--r-- | test/ParserTest.js | 108 | ||||
| -rw-r--r-- | test/ScopeTest.js | 32 | ||||
| -rw-r--r-- | test/ServerTest.js | 10 | ||||
| -rw-r--r-- | test/UsersTest.js | 4 | ||||
| -rw-r--r-- | test/WidgetsTest.js | 95 | ||||
| -rw-r--r-- | test/XSitePostTest.js | 47 | ||||
| -rw-r--r-- | test/formsTest.js | 4 | ||||
| -rw-r--r-- | test/testabilityPatch.js | 16 |
17 files changed, 356 insertions, 406 deletions
diff --git a/test/BinderTest.js b/test/BinderTest.js index d033996d..0ffd2120 100644 --- a/test/BinderTest.js +++ b/test/BinderTest.js @@ -3,10 +3,10 @@ BinderTest = TestCase('BinderTest'); function compile(content, initialScope, config) { var h = html(content); config = config || {autoSubmit:true}; - var scope = new nglr.Scope(initialScope, "ROOT"); + var scope = new Scope(initialScope, "ROOT"); h.data('scope', scope); - var binder = new nglr.Binder(h[0], new nglr.WidgetFactory(), new MockUrlWatcher(), config); - var datastore = new nglr.DataStore(); + var binder = new Binder(h[0], new WidgetFactory(), new MockUrlWatcher(), config); + var datastore = new DataStore(); scope.set("$datastore", datastore); scope.set("$binder", binder); scope.set("$anchor", binder.anchor); @@ -19,80 +19,79 @@ function compileToHtml(content) { return compile(content).node.sortedHtml(); } - BinderTest.prototype.testParseTextWithNoBindings = function(){ - var parts = nglr.Binder.parseBindings("a"); + var parts = Binder.parseBindings("a"); assertEquals(parts.length, 1); assertEquals(parts[0], "a"); - assertTrue(!nglr.Binder.binding(parts[0])); + assertTrue(!Binder.binding(parts[0])); }; BinderTest.prototype.testParseEmptyText = function(){ - var parts = nglr.Binder.parseBindings(""); + var parts = Binder.parseBindings(""); assertEquals(parts.length, 1); assertEquals(parts[0], ""); - assertTrue(!nglr.Binder.binding(parts[0])); + assertTrue(!Binder.binding(parts[0])); }; BinderTest.prototype.testParseInnerBinding = function(){ - var parts = nglr.Binder.parseBindings("a{{b}}c"); + var parts = Binder.parseBindings("a{{b}}c"); assertEquals(parts.length, 3); assertEquals(parts[0], "a"); - assertTrue(!nglr.Binder.binding(parts[0])); + assertTrue(!Binder.binding(parts[0])); assertEquals(parts[1], "{{b}}"); - assertEquals(nglr.Binder.binding(parts[1]), "b"); + assertEquals(Binder.binding(parts[1]), "b"); assertEquals(parts[2], "c"); - assertTrue(!nglr.Binder.binding(parts[2])); + assertTrue(!Binder.binding(parts[2])); }; BinderTest.prototype.testParseEndingBinding = function(){ - var parts = nglr.Binder.parseBindings("a{{b}}"); + var parts = Binder.parseBindings("a{{b}}"); assertEquals(parts.length, 2); assertEquals(parts[0], "a"); - assertTrue(!nglr.Binder.binding(parts[0])); + assertTrue(!Binder.binding(parts[0])); assertEquals(parts[1], "{{b}}"); - assertEquals(nglr.Binder.binding(parts[1]), "b"); + assertEquals(Binder.binding(parts[1]), "b"); }; BinderTest.prototype.testParseBeggingBinding = function(){ - var parts = nglr.Binder.parseBindings("{{b}}c"); + var parts = Binder.parseBindings("{{b}}c"); assertEquals(parts.length, 2); assertEquals(parts[0], "{{b}}"); - assertEquals(nglr.Binder.binding(parts[0]), "b"); + assertEquals(Binder.binding(parts[0]), "b"); assertEquals(parts[1], "c"); - assertTrue(!nglr.Binder.binding(parts[1])); + assertTrue(!Binder.binding(parts[1])); }; BinderTest.prototype.testParseLoanBinding = function(){ - var parts = nglr.Binder.parseBindings("{{b}}"); + var parts = Binder.parseBindings("{{b}}"); assertEquals(parts.length, 1); assertEquals(parts[0], "{{b}}"); - assertEquals(nglr.Binder.binding(parts[0]), "b"); + assertEquals(Binder.binding(parts[0]), "b"); }; BinderTest.prototype.testParseTwoBindings = function(){ - var parts = nglr.Binder.parseBindings("{{b}}{{c}}"); + var parts = Binder.parseBindings("{{b}}{{c}}"); assertEquals(parts.length, 2); assertEquals(parts[0], "{{b}}"); - assertEquals(nglr.Binder.binding(parts[0]), "b"); + assertEquals(Binder.binding(parts[0]), "b"); assertEquals(parts[1], "{{c}}"); - assertEquals(nglr.Binder.binding(parts[1]), "c"); + assertEquals(Binder.binding(parts[1]), "c"); }; BinderTest.prototype.testParseTwoBindingsWithTextInMiddle = function(){ - var parts = nglr.Binder.parseBindings("{{b}}x{{c}}"); + var parts = Binder.parseBindings("{{b}}x{{c}}"); assertEquals(parts.length, 3); assertEquals(parts[0], "{{b}}"); - assertEquals(nglr.Binder.binding(parts[0]), "b"); + assertEquals(Binder.binding(parts[0]), "b"); assertEquals(parts[1], "x"); - assertTrue(!nglr.Binder.binding(parts[1])); + assertTrue(!Binder.binding(parts[1])); assertEquals(parts[2], "{{c}}"); - assertEquals(nglr.Binder.binding(parts[2]), "c"); + assertEquals(Binder.binding(parts[2]), "c"); }; BinderTest.prototype.testParseMultiline = function(){ - var parts = nglr.Binder.parseBindings('"X\nY{{A\nB}}C\nD"'); - assertTrue(!!nglr.Binder.binding('{{A\nB}}')); + var parts = Binder.parseBindings('"X\nY{{A\nB}}C\nD"'); + assertTrue(!!Binder.binding('{{A\nB}}')); assertEquals(parts.length, 3); assertEquals(parts[0], '"X\nY'); assertEquals(parts[1], '{{A\nB}}'); @@ -100,9 +99,9 @@ BinderTest.prototype.testParseMultiline = function(){ }; BinderTest.prototype.testHasBinding = function(){ - assertTrue(nglr.Binder.hasBinding("{{a}}")); - assertTrue(!nglr.Binder.hasBinding("a")); - assertTrue(nglr.Binder.hasBinding("{{b}}x{{c}}")); + assertTrue(Binder.hasBinding("{{a}}")); + assertTrue(!Binder.hasBinding("a")); + assertTrue(Binder.hasBinding("{{b}}x{{c}}")); }; @@ -119,9 +118,9 @@ BinderTest.prototype.testChangingTextfieldUpdatesModel = function(){ BinderTest.prototype.testChangingTextareaUpdatesModel = function(){ var form = html('<textarea name="model.note">abc</textarea>'); - var scope = new nglr.Scope({model:{}}); + var scope = new Scope({model:{}}); form.data('scope', scope); - var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); binder.compile(); binder.updateView(); assertEquals(scope.get('model').note, 'abc'); @@ -130,9 +129,9 @@ BinderTest.prototype.testChangingTextareaUpdatesModel = function(){ BinderTest.prototype.testChangingRadioUpdatesModel = function(){ var form = html('<input type="radio" name="model.price" value="A" checked>' + '<input type="radio" name="model.price" value="B">'); - var scope = new nglr.Scope({model:{}}); + var scope = new Scope({model:{}}); form.data('scope', scope); - var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); binder.compile(); binder.updateView(); assertEquals(scope.get('model').price, 'A'); @@ -140,9 +139,9 @@ BinderTest.prototype.testChangingRadioUpdatesModel = function(){ BinderTest.prototype.testChangingCheckboxUpdatesModel = function(){ var form = html('<input type="checkbox" name="model.price" value="A" checked>'); - var scope = new nglr.Scope({model:{}}); + var scope = new Scope({model:{}}); form.data('scope', scope); - var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); binder.compile(); binder.updateView(); assertEquals('A', scope.get('model').price); @@ -156,9 +155,9 @@ BinderTest.prototype.testBindUpdate = function() { BinderTest.prototype.testChangingSelectNonSelectedUpdatesModel = function(){ var form = html('<select name="model.price"><option value="A">A</option><option value="B">B</option></select>'); - var scope = new nglr.Scope({model:{}}); + var scope = new Scope({model:{}}); form.data('scope', scope); - var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); binder.compile(); binder.updateView(); assertEquals('A', scope.get('model').price); @@ -170,9 +169,9 @@ BinderTest.prototype.testChangingMultiselectUpdatesModel = function(){ '<option value="B" selected>Extra padding</option>' + '<option value="C">Expedite</option>' + '</select>'); - var scope = new nglr.Scope({Invoice:{}}); + var scope = new Scope({Invoice:{}}); form.data('scope', scope); - var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); binder.compile(); binder.updateView(); assertJsonEquals(["A", "B"], scope.get('Invoice').options); @@ -180,9 +179,9 @@ BinderTest.prototype.testChangingMultiselectUpdatesModel = function(){ BinderTest.prototype.testChangingSelectSelectedUpdatesModel = function(){ var form = html('<select name="model.price"><option>A</option><option selected value="b">B</option></select>'); - var scope = new nglr.Scope({model:{}}); + var scope = new Scope({model:{}}); form.data('scope', scope); - var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); binder.compile(); binder.updateView(); assertEquals(scope.get('model').price, 'b'); @@ -190,18 +189,18 @@ BinderTest.prototype.testChangingSelectSelectedUpdatesModel = function(){ BinderTest.prototype.testExecuteInitialization = function() { var form = html('<div ng-init="a=123">'); - var scope = new nglr.Scope(); + var scope = new Scope(); form.data('scope', scope); - var binder = new nglr.Binder(form.get(0)); + var binder = new Binder(form.get(0)); binder.executeInit(); assertEquals(scope.get('a'), 123); }; BinderTest.prototype.testExecuteInitializationStatements = function() { var form = html('<div ng-init="a=123;b=345">'); - var scope = new nglr.Scope(); + var scope = new Scope(); form.data('scope', scope); - var binder = new nglr.Binder(form.get(0)); + var binder = new Binder(form.get(0)); binder.executeInit(); assertEquals(scope.get('a'), 123); assertEquals(scope.get('b'), 345); @@ -209,9 +208,9 @@ BinderTest.prototype.testExecuteInitializationStatements = function() { BinderTest.prototype.testApplyTextBindings = function(){ var form = html('<div ng-bind="model.a">x</div>'); - var scope = new nglr.Scope({model:{a:123}}); + var scope = new Scope({model:{a:123}}); form.data('scope', scope); - var binder = new nglr.Binder(form.get(0), null, new MockUrlWatcher()); + var binder = new Binder(form.get(0), null, new MockUrlWatcher()); binder.compile(); binder.updateView(); assertEquals('123', form.text()); @@ -224,15 +223,15 @@ BinderTest.prototype.testReplaceBindingInTextWithSpan = function() { BinderTest.prototype.testReplaceBindingCreatesCorrectNumberOfWidgets = function() { var h = html("space{{a}}<b>{{a}}a{{a}}</b>{{a}}"); - h.data('scope', new nglr.Scope()); - var binder = new nglr.Binder(h.get(0), new nglr.WidgetFactory()); + h.data('scope', new Scope()); + var binder = new Binder(h.get(0), new WidgetFactory()); binder.compile(); assertEquals(4, h.scope().widgets.length); }; BinderTest.prototype.testBindingSpaceConfusesIE = function() { - if (!nglr.msie) return; + if (!msie) return; var span = document.createElement("span"); span.innerHTML = ' '; var nbsp = span.firstChild.nodeValue; @@ -246,30 +245,30 @@ BinderTest.prototype.testBindingSpaceConfusesIE = function() { BinderTest.prototype.testBindingOfAttributes = function() { var form = html("<a href='http://s/a{{b}}c' foo='x'></a>"); - form.data('scope', new nglr.Scope()); - var binder = new nglr.Binder(form.get(0)); + form.data('scope', new Scope()); + var binder = new Binder(form.get(0)); binder.compile(); var attrbinding = form.find("a").attr("ng-bind-attr"); - var bindings = nglr.fromJson(attrbinding); + var bindings = fromJson(attrbinding); assertEquals("http://s/a{{b}}c", decodeURI(bindings.href)); assertTrue(!bindings.foo); }; BinderTest.prototype.testMarkMultipleAttributes = function() { var form = html("<a href='http://s/a{{b}}c' foo='{{d}}'></a>"); - form.data('scope', new nglr.Scope()); - var binder = new nglr.Binder(form.get(0)); + form.data('scope', new Scope()); + var binder = new Binder(form.get(0)); binder.compile(); var attrbinding = form.find("a").attr("ng-bind-attr"); - var bindings = nglr.fromJson(attrbinding); + var bindings = fromJson(attrbinding); assertEquals(decodeURI(bindings.href), "http://s/a{{b}}c"); assertEquals(bindings.foo, "{{d}}"); }; BinderTest.prototype.testAttributesNoneBound = function() { var form = html("<a href='abc' foo='def'></a>"); - form.data('scope', new nglr.Scope()); - var binder = new nglr.Binder(form.get(0)); + form.data('scope', new Scope()); + var binder = new Binder(form.get(0)); binder.compile(); var a = form.find("a"); assertEquals(a.get(0).nodeName, "A"); @@ -278,8 +277,8 @@ BinderTest.prototype.testAttributesNoneBound = function() { BinderTest.prototype.testExistingAttrbindingIsAppended = function() { var form = html("<a href='http://s/{{abc}}' ng-bind-attr='{\"b\":\"{{def}}\"}'></a>"); - form.data('scope', new nglr.Scope()); - var binder = new nglr.Binder(form.get(0)); + form.data('scope', new Scope()); + var binder = new Binder(form.get(0)); binder.compile(); var a = form.find("a"); assertEquals('{"b":"{{def}}","href":"http://s/{{abc}}"}', a.attr('ng-bind-attr')); @@ -287,8 +286,8 @@ BinderTest.prototype.testExistingAttrbindingIsAppended = function() { BinderTest.prototype.testAttributesAreEvaluated = function(){ var form = html('<a ng-bind-attr=\'{"a":"a", "b":"a+b={{a+b}}"}\'></a>'); - form.data('scope', new nglr.Scope({a:1, b:2})); - var binder = new nglr.Binder(form.get(0), null, new MockUrlWatcher()); + form.data('scope', new Scope({a:1, b:2})); + var binder = new Binder(form.get(0), null, new MockUrlWatcher()); binder.compile(); binder.updateView(); var a = form.find("a"); @@ -305,8 +304,8 @@ BinderTest.prototype.testInputsAreUpdated = function(){ '<input name="A.checkbox" type="checkbox" value="c" />' + '<input name="A.checkboxOff" type="checkbox" value="c" />' + '<select name="A.select"><option>a</option><option value="S">b</option></select>'); - var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher()); - form.data('scope', new nglr.Scope({A:{text:"t1", textarea:"t2", radio:"r", checkbox:"c", select:"S"}})); + var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher()); + form.data('scope', new Scope({A:{text:"t1", textarea:"t2", radio:"r", checkbox:"c", select:"S"}})); binder.compile(); binder.updateView(); assertEquals(form.find("input[type=text]").attr('value'), 't1'); @@ -349,7 +348,7 @@ BinderTest.prototype.testButtonElementActionExecutesInScope = function(){ }; BinderTest.prototype.testParseEmptyAnchor = function(){ - var binder = new nglr.Binder(null, null, new MockUrlWatcher()); + var binder = new Binder(null, null, new MockUrlWatcher()); var anchor = binder.anchor; binder.parseAnchor("a#x=1"); assertEquals(1, binder.anchor.x); @@ -360,7 +359,7 @@ BinderTest.prototype.testParseEmptyAnchor = function(){ }; BinderTest.prototype.testParseAnchor = function(){ - var binder = new nglr.Binder(null, null, new MockUrlWatcher()); + var binder = new Binder(null, null, new MockUrlWatcher()); binder.parseAnchor("a#x=1"); assertEquals(binder.anchor.x, "1"); binder.parseAnchor("a#a=b&c=%20&d"); @@ -371,7 +370,7 @@ BinderTest.prototype.testParseAnchor = function(){ }; BinderTest.prototype.testWriteAnchor = function(){ - var binder = new nglr.Binder(null, null, new MockUrlWatcher()); + var binder = new Binder(null, null, new MockUrlWatcher()); binder.urlWatcher.setUrl('a'); binder.anchor.a = 'b'; binder.anchor.c = ' '; @@ -381,9 +380,9 @@ BinderTest.prototype.testWriteAnchor = function(){ }; BinderTest.prototype.testWriteAnchorAsPartOfTheUpdateView = function(){ - var binder = new nglr.Binder(html("<div/>")[0], null, new MockUrlWatcher()); + var binder = new Binder(html("<div/>")[0], null, new MockUrlWatcher()); binder.urlWatcher.setUrl('a'); - $(binder.doc).data('scope', new nglr.Scope()); + $(binder.doc).data('scope', new Scope()); binder.anchor.a = 'b'; binder.updateView(); assertEquals(binder.urlWatcher.getUrl(), "a#a=b"); @@ -391,9 +390,9 @@ BinderTest.prototype.testWriteAnchorAsPartOfTheUpdateView = function(){ BinderTest.prototype.testRepeaterUpdateBindings = function(){ var form = html('<ul><LI ng-repeat="item in model.items" ng-bind="item.a"/></ul>'); - var binder = new nglr.Binder(form.get(0), null, new MockUrlWatcher()); + var binder = new Binder(form.get(0), null, new MockUrlWatcher()); var items = [{a:"A"}, {a:"B"}]; - form.data('scope', new nglr.Scope({model:{items:items}})); + form.data('scope', new Scope({model:{items:items}})); binder.compile(); binder.updateView(); @@ -423,8 +422,8 @@ BinderTest.prototype.testRepeaterUpdateBindings = function(){ BinderTest.prototype.testRepeaterContentDoesNotBind = function(){ var form = html('<ul><LI ng-repeat="item in model.items"><span ng-bind="item.a"/></li></ul>'); - form.data('scope', new nglr.Scope({model:{items:[{a:"A"}]}})); - var binder = new nglr.Binder(form.get(0), null, new MockUrlWatcher()); + form.data('scope', new Scope({model:{items:[{a:"A"}]}})); + var binder = new Binder(form.get(0), null, new MockUrlWatcher()); binder.compile(); binder.updateView(); assertEquals('<ul>' + @@ -450,9 +449,9 @@ BinderTest.prototype.testRepeaterInputContentDoesNotBind = function(){ var form = html('<ul><LI repeater="item in model.items">' + '<input type="text" name="item.a" value="OLD"/></li></ul>'); - var binder = new nglr.Binder(form.get(0), null, new MockUrlWatcher()); + var binder = new Binder(form.get(0), null, new MockUrlWatcher()); var items = [{a:"A"}]; - form.data('scope', new nglr.Scope({model:{items:items}})); + form.data('scope', new Scope({model:{items:items}})); assertEquals(form.find(":input").attr("value"), "OLD"); }; @@ -492,9 +491,9 @@ BinderTest.prototype.testDoNotOverwriteCustomAction = function(){ BinderTest.prototype.testReplaceFileUploadWithSwf = function(){ expectAsserts(1); var form = jQuery("body").append('<div id="testTag"><input type="file"></div>'); - form.data('scope', new nglr.Scope()); + form.data('scope', new Scope()); var factory = {}; - var binder = new nglr.Binder(form.get(0), factory, new MockUrlWatcher()); + var binder = new Binder(form.get(0), factory, new MockUrlWatcher()); factory.createController = function(node){ assertEquals(node.attr('type'), 'file'); return {updateModel:function(){}}; @@ -505,8 +504,8 @@ BinderTest.prototype.testReplaceFileUploadWithSwf = function(){ BinderTest.prototype.testRepeaterAdd = function(){ var doc = $('<div><input type="text" name="item.x" ng-repeat="item in items"></div>'); - var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher()); - doc.data('scope', new nglr.Scope({items:[{x:'a'}, {x:'b'}], $binder:binder})); + var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher()); + doc.data('scope', new Scope({items:[{x:'a'}, {x:'b'}], $binder:binder})); binder.compile(); binder.updateView(); assertEquals('a', doc.find(':input')[0].value); @@ -520,16 +519,16 @@ BinderTest.prototype.testRepeaterAdd = function(){ BinderTest.prototype.testIfTextBindingThrowsErrorDecorateTheSpan = function(){ var doc = $('<div>{{error.throw()}}</div>'); - var scope = new nglr.Scope(); + var scope = new Scope(); doc.data('scope', scope); - var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher()); binder.compile(); scope.set('error.throw', function(){throw "ErrorMsg1";}); binder.updateView(); var span = doc.find('span'); assertTrue(span.hasClass('ng-exception')); - assertEquals('ErrorMsg1', nglr.fromJson(span.text())); + assertEquals('ErrorMsg1', fromJson(span.text())); assertEquals('"ErrorMsg1"', span.attr('ng-error')); scope.set('error.throw', function(){throw "MyError";}); @@ -548,9 +547,9 @@ BinderTest.prototype.testIfTextBindingThrowsErrorDecorateTheSpan = function(){ BinderTest.prototype.testIfAttrBindingThrowsErrorDecorateTheSpan = function(){ var doc = $('<div attr="before {{error.throw()}} after"/>'); - var scope = new nglr.Scope(); + var scope = new Scope(); doc.data('scope', scope); - var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher()); binder.compile(); scope.set('error.throw', function(){throw "ErrorMsg";}); @@ -570,9 +569,9 @@ BinderTest.prototype.testNestedRepeater = function() { var doc = html('<div ng-repeat="m in model" name="{{m.name}}">' + '<ul name="{{i}}" ng-repeat="i in m.item"></ul>' + '</div>'); - var scope = new nglr.Scope(); + var scope = new Scope(); doc.data('scope', scope); - var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher()); binder.compile(); scope.set('model', [{name:'a', item:['a1', 'a2']}, {name:'b', item:['b1', 'b2']}]); @@ -594,9 +593,9 @@ BinderTest.prototype.testNestedRepeater = function() { BinderTest.prototype.testRadioButtonGetsPrefixed = function () { var doc = html('<input ng-repeat="m in model" type="radio" name="m.a" value="on"/>'); - var scope = new nglr.Scope(); + var scope = new Scope(); doc.data('scope', scope); - var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher()); binder.compile(); scope.set('model', ['a1', 'a2']); @@ -611,9 +610,9 @@ BinderTest.prototype.testRadioButtonGetsPrefixed = function () { BinderTest.prototype.testHideBindingExpression = function() { var doc = html('<div ng-hide="hidden == 3"/>'); - var scope = new nglr.Scope(); + var scope = new Scope(); doc.data('scope', scope); - var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher()); binder.compile(); scope.set('hidden', 3); @@ -629,9 +628,9 @@ BinderTest.prototype.testHideBindingExpression = function() { BinderTest.prototype.testHideBinding = function() { var doc = html('<div ng-hide="hidden"/>'); - var scope = new nglr.Scope(); + var scope = new Scope(); doc.data('scope', scope); - var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher()); binder.compile(); scope.set('hidden', 'true'); @@ -652,9 +651,9 @@ BinderTest.prototype.testHideBinding = function() { BinderTest.prototype.testShowBinding = function() { var doc = html('<div ng-show="show"/>'); - var scope = new nglr.Scope(); + var scope = new Scope(); doc.data('scope', scope); - var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher()); binder.compile(); scope.set('show', 'true'); @@ -684,9 +683,9 @@ BinderTest.prototype.testBindClassUndefined = function() { BinderTest.prototype.testBindClass = function() { var doc = html('<div ng-class="class"/>'); - var scope = new nglr.Scope(); + var scope = new Scope(); doc.data('scope', scope); - var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher()); binder.compile(); scope.set('class', 'testClass'); @@ -713,9 +712,9 @@ BinderTest.prototype.testBindClassEvenOdd = function() { BinderTest.prototype.testBindStyle = function() { var doc = html('<div ng-style="style"/>'); - var scope = new nglr.Scope(); + var scope = new Scope(); doc.data('scope', scope); - var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher()); + var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher()); binder.compile(); scope.eval('style={color:"red"}'); @@ -734,7 +733,7 @@ BinderTest.prototype.testActionOnAHrefThrowsError = function(){ var state = compile('<a ng-action="throw {a:\'abc\', b:2};">Add Phone</a>', model); var input = state.node.find('a'); input.click(); - assertEquals('abc', nglr.fromJson(input.attr('ng-error')).a); + assertEquals('abc', fromJson(input.attr('ng-error')).a); assertNotNull(input.data('qtip')); assertTrue("should have an error class", input.hasClass('ng-exception')); @@ -890,7 +889,7 @@ BinderTest.prototype.testItShouldCallListenersWhenAnchorChanges = function() { }; BinderTest.prototype.testParseQueryString = function(){ - var binder = new nglr.Binder(); + var binder = new Binder(); assertJsonEquals({"a":"1"}, binder.parseQueryString("a=1")); assertJsonEquals({"a":"1", "b":"two"}, binder.parseQueryString("a=1&b=two")); assertJsonEquals({}, binder.parseQueryString("")); @@ -905,8 +904,8 @@ BinderTest.prototype.testParseQueryString = function(){ BinderTest.prototype.testSetBinderAnchorTriggersListeners = function(){ expectAsserts(2); var doc = html("<div/>")[0]; - var binder = new nglr.Binder(doc, null, new MockUrlWatcher()); - var scope = new nglr.Scope({$binder:binder, $anchor:binder.anchor}); + var binder = new Binder(doc, null, new MockUrlWatcher()); + var scope = new Scope({$binder:binder, $anchor:binder.anchor}); jQuery(doc).data('scope', scope); scope.addWatchListener("$anchor.name", function(newVal, oldVal) { diff --git a/test/ConsoleTest.js b/test/ConsoleTest.js index 56e223bd..f659752f 100644 --- a/test/ConsoleTest.js +++ b/test/ConsoleTest.js @@ -1,13 +1,12 @@ ConsoleTest = TestCase('ConsoleTest'); ConsoleTest.prototype.testConsoleWrite = function(){ - var consoleNode = $("<div></div>")[0]; - nglr.consoleNode = consoleNode; - nglr.consoleLog("error", ["Hello", "world"]); + consoleNode = $("<div></div>")[0]; + consoleLog("error", ["Hello", "world"]); assertEquals($(consoleNode)[0].nodeName, 'DIV'); assertEquals($(consoleNode).text(), 'Hello world'); assertEquals($('div', consoleNode)[0].className, 'error'); - nglr.consoleLog("error",["Bye"]); + consoleLog("error",["Bye"]); assertEquals($(consoleNode).text(), 'Hello worldBye'); - nglr.consoleNode = null; + consoleNode = null; };
\ No newline at end of file diff --git a/test/DataStoreTest.js b/test/DataStoreTest.js index 9fe6c3df..2dd4a582 100644 --- a/test/DataStoreTest.js +++ b/test/DataStoreTest.js @@ -11,14 +11,14 @@ DataStoreTest.prototype.testSavePostsToServer = function(){ assertEquals("123", posted.$id); assertEquals("1", posted.$version); assertFalse('function' == typeof posted.save); - response = nglr.fromJson(nglr.toJson(posted)); + response = fromJson(toJson(posted)); response.$entity = "abc"; response.$id = "123"; response.$version = "2"; callback(200, [response]); }; var model; - var datastore = new nglr.DataStore(post); + var datastore = new DataStore(post); model = datastore.entity('abc', {name: "value"})(); model.$id = "123"; model.$version = "1"; @@ -44,7 +44,7 @@ DataStoreTest.prototype.testLoadGetsFromServer = function(){ response = [{$entity:'abc', $id:'1', $version:'2', key:"value"}]; callback(200, response); }; - var datastore = new nglr.DataStore(post); + var datastore = new DataStore(post); var model = datastore.entity("abc", {merge:true})(); assertEquals(datastore.load(model, '1', function(obj){ @@ -72,14 +72,14 @@ DataStoreTest.prototype.testRemove = function(){ assertEquals("123", posted.$id); assertEquals("1", posted.$version); assertFalse('function' == typeof posted.save); - response = nglr.fromJson(nglr.toJson(posted)); + response = fromJson(toJson(posted)); response.$entity = "abc"; response.$id = "123"; response.$version = "2"; callback(200, [response]); }; var model; - var datastore = new nglr.DataStore(post); + var datastore = new DataStore(post); model = datastore.entity('abc', {name: "value"})(); model.$id = "123"; model.$version = "1"; @@ -101,7 +101,7 @@ DataStoreTest.prototype.test401ResponseDoesNotCallCallback = function(){ callback(200, {$status_code: 401}); }; - var datastore = new nglr.DataStore(post, {login:function(){ + var datastore = new DataStore(post, {login:function(){ assertTrue(true); }}); @@ -119,7 +119,7 @@ DataStoreTest.prototype.test403ResponseDoesNotCallCallback = function(){ callback(200, [{$status_code: 403}]); }; - var datastore = new nglr.DataStore(post, {notAuthorized:function(){ + var datastore = new DataStore(post, {notAuthorized:function(){ assertTrue(true); }}); @@ -136,14 +136,14 @@ DataStoreTest.prototype.testLoadCalledWithoutIdShouldBeNoop = function(){ var post = function(url, callback){ assertTrue(false); }; - var datastore = new nglr.DataStore(post); + var datastore = new DataStore(post); var model = datastore.entity("abc")(); assertEquals(datastore.load(model, undefined), model); assertEquals(model.$entity, "abc"); }; DataStoreTest.prototype.testEntityFactory = function(){ - var ds = new nglr.DataStore(); + var ds = new DataStore(); var Recipe = ds.entity("Recipe", {a:1, b:2}); assertEquals(Recipe.title, "Recipe"); assertEquals(Recipe.defaults.a, 1); @@ -161,7 +161,7 @@ DataStoreTest.prototype.testEntityFactory = function(){ }; DataStoreTest.prototype.testEntityFactoryNoDefaults = function(){ - var ds = new nglr.DataStore(); + var ds = new DataStore(); var Recipe = ds.entity("Recipe"); assertEquals(Recipe.title, "Recipe"); @@ -170,7 +170,7 @@ DataStoreTest.prototype.testEntityFactoryNoDefaults = function(){ }; DataStoreTest.prototype.testEntityFactoryWithInitialValues = function(){ - var ds = new nglr.DataStore(); + var ds = new DataStore(); var Recipe = ds.entity("Recipe"); var recipe = Recipe({name: "name"}); @@ -178,7 +178,7 @@ DataStoreTest.prototype.testEntityFactoryWithInitialValues = function(){ }; DataStoreTest.prototype.testEntityLoad = function(){ - var ds = new nglr.DataStore(); + var ds = new DataStore(); var Recipe = ds.entity("Recipe", {a:1, b:2}); ds.load = function(instance, id, callback){ callback.apply(instance); @@ -192,7 +192,7 @@ DataStoreTest.prototype.testEntityLoad = function(){ }; DataStoreTest.prototype.testSaveScope = function(){ - var ds = new nglr.DataStore(); + var ds = new DataStore(); var log = ""; var Person = ds.entity("Person"); var person1 = Person({name:"A", $entity:"Person", $id:"1", $version:"1"}, ds); @@ -215,7 +215,7 @@ DataStoreTest.prototype.testSaveScope = function(){ }; DataStoreTest.prototype.testEntityLoadAllRows = function(){ - var ds = new nglr.DataStore(); + var ds = new DataStore(); var Recipe = ds.entity("Recipe"); var list = []; ds.loadAll = function(entity, callback){ @@ -236,7 +236,7 @@ DataStoreTest.prototype.testLoadAll = function(){ assertEquals("A", data[0][1]); callback(200, [[{$entity:'A', $id:'1'},{$entity:'A', $id:'2'}]]); }; - var datastore = new nglr.DataStore(post); + var datastore = new DataStore(post); var list = datastore.entity("A").all(function(){ assertTrue(true); }); @@ -256,7 +256,7 @@ DataStoreTest.prototype.testQuery = function(){ callback(200, [[{$entity:"Employee", $id: "456", managerId: "123ABC"}]]); }; - var datastore = new nglr.DataStore(post); + var datastore = new DataStore(post); var Employee = datastore.entity("Employee"); var list = Employee.query('managerId', "123abc", function(){ assertTrue(true); @@ -269,7 +269,7 @@ DataStoreTest.prototype.testQuery = function(){ DataStoreTest.prototype.testLoadingDocumentRefreshesExistingArrays = function() { expectAsserts(12); var post; - var datastore = new nglr.DataStore(function(r, c){post(r,c);}); + var datastore = new DataStore(function(r, c){post(r,c);}); var Book = datastore.entity('Book'); post = function(req, callback) { callback(200, [[{$id:1, $entity:"Book", name:"Moby"}, @@ -285,7 +285,7 @@ DataStoreTest.prototype.testLoadingDocumentRefreshesExistingArrays = function() assertEquals("Dick", queryBooks[1].name); post = function(req, callback) { - assertEquals('[["GET","Book/1"]]', nglr.toJson(req)); + assertEquals('[["GET","Book/1"]]', toJson(req)); callback(200, [{$id:1, $entity:"Book", name:"Moby Dick"}]); }; var book = Book.load(1); @@ -307,7 +307,7 @@ DataStoreTest.prototype.testLoadingDocumentRefreshesExistingArrays = function() DataStoreTest.prototype.testEntityProperties = function() { expectAsserts(2); - var datastore = new nglr.DataStore(); + var datastore = new DataStore(); var callback = {}; datastore._jsonRequest = function(request, callbackFn) { @@ -322,11 +322,11 @@ DataStoreTest.prototype.testEntityProperties = function() { DataStoreTest.prototype.testLoadInstanceIsNotFromCache = function() { var post; - var datastore = new nglr.DataStore(function(r, c){post(r,c);}); + var datastore = new DataStore(function(r, c){post(r,c);}); var Book = datastore.entity('Book'); post = function(req, callback) { - assertEquals('[["GET","Book/1"]]', nglr.toJson(req)); + assertEquals('[["GET","Book/1"]]', toJson(req)); callback(200, [{$id:1, $entity:"Book", name:"Moby Dick"}]); }; var book = Book.load(1); @@ -336,14 +336,14 @@ DataStoreTest.prototype.testLoadInstanceIsNotFromCache = function() { }; DataStoreTest.prototype.testLoadStarsIsNewDocument = function() { - var datastore = new nglr.DataStore(); + var datastore = new DataStore(); var Book = datastore.entity('Book'); var book = Book.load('*'); assertEquals('Book', book.$entity); }; DataStoreTest.prototype.testUndefinedEntityReturnsNullValueObject = function() { - var datastore = new nglr.DataStore(); + var datastore = new DataStore(); var Entity = datastore.entity(undefined); var all = Entity.all(); assertEquals(0, all.length); @@ -355,7 +355,7 @@ DataStoreTest.prototype.testFetchEntities = function(){ assertJsonEquals(["GET", "$entities"], data[0]); callback(200, [{A:0, B:0}]); }; - var datastore = new nglr.DataStore(post); + var datastore = new DataStore(post); var entities = datastore.entities(function(){ assertTrue(true); }); @@ -367,20 +367,20 @@ DataStoreTest.prototype.testFetchEntities = function(){ }; DataStoreTest.prototype.testItShouldMigrateSchema = function() { - var datastore = new nglr.DataStore(); + var datastore = new DataStore(); var Entity = datastore.entity("Entity", {a:[], user:{name:"Misko", email:""}}); var doc = Entity().$loadFrom({b:'abc', user:{email:"misko@hevery.com"}}); assertFalse( - nglr.toJson({a:[], b:'abc', user:{name:"Misko", email:"misko@hevery.com"}}) == - nglr.toJson(doc)); + toJson({a:[], b:'abc', user:{name:"Misko", email:"misko@hevery.com"}}) == + toJson(doc)); doc.$migrate(); assertEquals( - nglr.toJson({a:[], b:'abc', user:{name:"Misko", email:"misko@hevery.com"}}), - nglr.toJson(doc)); + toJson({a:[], b:'abc', user:{name:"Misko", email:"misko@hevery.com"}}), + toJson(doc)); }; DataStoreTest.prototype.testItShouldCollectRequestsForBulk = function() { - var ds = new nglr.DataStore(); + var ds = new DataStore(); var Book = ds.entity("Book"); var Library = ds.entity("Library"); Book.all(); @@ -391,7 +391,7 @@ DataStoreTest.prototype.testItShouldCollectRequestsForBulk = function() { }; DataStoreTest.prototype.testEmptyFlushShouldDoNothing = function () { - var ds = new nglr.DataStore(function(){ + var ds = new DataStore(function(){ fail("expecting noop"); }); ds.flush(); @@ -400,17 +400,17 @@ DataStoreTest.prototype.testEmptyFlushShouldDoNothing = function () { DataStoreTest.prototype.testFlushShouldCallAllCallbacks = function() { var log = ""; function post(request, callback){ - log += 'BulkRequest:' + nglr.toJson(request) + ';'; + log += 'BulkRequest:' + toJson(request) + ';'; callback(200, [[{$id:'ABC'}], {$id:'XYZ'}]); } - var ds = new nglr.DataStore(post); + var ds = new DataStore(post); var Book = ds.entity("Book"); var Library = ds.entity("Library"); Book.all(function(instance){ - log += nglr.toJson(instance) + ';'; + log += toJson(instance) + ';'; }); Library.load("123", function(instance){ - log += nglr.toJson(instance) + ';'; + log += toJson(instance) + ';'; }); assertEquals("", log); ds.flush(); @@ -421,7 +421,7 @@ DataStoreTest.prototype.testFlushShouldCallAllCallbacks = function() { DataStoreTest.prototype.testSaveOnNotLoggedInRetriesAfterLoggin = function(){ var log = ""; var book; - var ds = new nglr.DataStore(null, {login:function(c){c();}}); + var ds = new DataStore(null, {login:function(c){c();}}); ds.post = function (request, callback){ assertJsonEquals([["POST", "", book]], request); ds.post = function(request, callback){ @@ -439,7 +439,7 @@ DataStoreTest.prototype.testSaveOnNotLoggedInRetriesAfterLoggin = function(){ DataStoreTest.prototype.testItShouldRemoveItemFromCollectionWhenDeleted = function() { expectAsserts(6); - var ds = new nglr.DataStore(); + var ds = new DataStore(); ds.post = function(request, callback){ assertJsonEquals([["GET", "Book"]], request); callback(200, [[{name:"Moby Dick", $id:123, $entity:'Book'}]]); @@ -462,7 +462,7 @@ DataStoreTest.prototype.testItShouldRemoveItemFromCollectionWhenDeleted = functi DataStoreTest.prototype.testItShouldAddToAll = function() { expectAsserts(8); - var ds = new nglr.DataStore(); + var ds = new DataStore(); ds.post = function(request, callback){ assertJsonEquals([["GET", "Book"]], request); callback(200, [[]]); @@ -490,7 +490,7 @@ DataStoreTest.prototype.testItShouldAddToAll = function() { DataStoreTest.prototype.testItShouldReturnCreatedDocumentCountByUser = function(){ expectAsserts(2); - var datastore = new nglr.DataStore( + var datastore = new DataStore( function(request, callback){ assertJsonEquals([["GET", "$users"]], request); callback(200, [{misko:1, adam:1}]); @@ -502,7 +502,7 @@ DataStoreTest.prototype.testItShouldReturnCreatedDocumentCountByUser = function( DataStoreTest.prototype.testItShouldReturnDocumentIdsForUeserByEntity = function(){ expectAsserts(2); - var datastore = new nglr.DataStore( + var datastore = new DataStore( function(request, callback){ assertJsonEquals([["GET", "$users/misko@hevery.com"]], request); callback(200, [{Book:["1"], Library:["2"]}]); @@ -514,7 +514,7 @@ DataStoreTest.prototype.testItShouldReturnDocumentIdsForUeserByEntity = function DataStoreTest.prototype.testItShouldReturnNewInstanceOn404 = function(){ expectAsserts(7); var log = ""; - var datastore = new nglr.DataStore( + var datastore = new DataStore( function(request, callback){ assertJsonEquals([["GET", "User/misko"]], request); callback(200, [{$status_code:404}]); @@ -532,13 +532,13 @@ DataStoreTest.prototype.testItShouldReturnNewInstanceOn404 = function(){ DataStoreTest.prototype.testItShouldReturnNewInstanceOn404 = function(){ var log = ""; - var datastore = new nglr.DataStore( + var datastore = new DataStore( function(request, callback){ assertJsonEquals([["GET", "User/misko"],["GET", "User/adam"]], request); callback(200, [{$id:'misko'},{$id:'adam'}]); }); var User = datastore.entity("User"); - var users = User.loadMany(['misko', 'adam'], function(i){log+="cb "+nglr.toJson(i)+";";}); + var users = User.loadMany(['misko', 'adam'], function(i){log+="cb "+toJson(i)+";";}); datastore.flush(); assertEquals("misko", users[0].$id); assertEquals("adam", users[1].$id); @@ -546,7 +546,7 @@ DataStoreTest.prototype.testItShouldReturnNewInstanceOn404 = function(){ }; DataStoreTest.prototype.testItShouldCreateJoinAndQuery = function() { - var datastore = new nglr.DataStore(); + var datastore = new DataStore(); var Invoice = datastore.entity("Invoice"); var Customer = datastore.entity("Customer"); var InvoiceWithCustomer = datastore.join({ @@ -568,7 +568,7 @@ DataStoreTest.prototype.testItShouldCreateJoinAndQuery = function() { }; DataStoreTest.prototype.testItShouldThrowIfMoreThanOneEntityIsPrimary = function() { - var datastore = new nglr.DataStore(); + var datastore = new DataStore(); var Invoice = datastore.entity("Invoice"); var Customer = datastore.entity("Customer"); assertThrows("Exactly one entity needs to be primary.", function(){ @@ -580,7 +580,7 @@ DataStoreTest.prototype.testItShouldThrowIfMoreThanOneEntityIsPrimary = function }; DataStoreTest.prototype.testItShouldThrowIfLoopInReferences = function() { - var datastore = new nglr.DataStore(); + var datastore = new DataStore(); var Invoice = datastore.entity("Invoice"); var Customer = datastore.entity("Customer"); assertThrows("Infinite loop in join: invoice -> customer", function(){ @@ -592,7 +592,7 @@ DataStoreTest.prototype.testItShouldThrowIfLoopInReferences = function() { }; DataStoreTest.prototype.testItShouldThrowIfReferenceToNonExistantJoin = function() { - var datastore = new nglr.DataStore(); + var datastore = new DataStore(); var Invoice = datastore.entity("Invoice"); var Customer = datastore.entity("Customer"); assertThrows("Named entity 'x' is undefined.", function(){ @@ -604,7 +604,7 @@ DataStoreTest.prototype.testItShouldThrowIfReferenceToNonExistantJoin = function }; DataStoreTest.prototype.testItShouldThrowIfQueryOnNonPrimary = function() { - var datastore = new nglr.DataStore(); + var datastore = new DataStore(); var Invoice = datastore.entity("Invoice"); var Customer = datastore.entity("Customer"); var InvoiceWithCustomer = datastore.join({ diff --git a/test/EntityDeclarationTest.js b/test/EntityDeclarationTest.js index 5cab90f4..d64dd775 100644 --- a/test/EntityDeclarationTest.js +++ b/test/EntityDeclarationTest.js @@ -2,7 +2,7 @@ EntityDeclarationTest = TestCase('EntityDeclarationTest'); EntityDeclarationTest.prototype.testEntityTypeOnly = function(){ expectAsserts(2); - var scope = new nglr.Scope({$datastore:{entity:function(name){ + var scope = new Scope({$datastore:{entity:function(name){ assertEquals("Person", name); }}}); var init = scope.entity("Person"); @@ -11,7 +11,7 @@ EntityDeclarationTest.prototype.testEntityTypeOnly = function(){ EntityDeclarationTest.prototype.testWithDefaults = function(){ expectAsserts(4); - var scope = new nglr.Scope({$datastore:{entity:function(name, init){ + var scope = new Scope({$datastore:{entity:function(name, init){ assertEquals("Person", name); assertEquals("=a:", init.a); assertEquals(0, init.b.length); @@ -22,7 +22,7 @@ EntityDeclarationTest.prototype.testWithDefaults = function(){ EntityDeclarationTest.prototype.testWithName = function(){ expectAsserts(2); - var scope = new nglr.Scope({$datastore:{entity:function(name, init){ + var scope = new Scope({$datastore:{entity:function(name, init){ assertEquals("Person", name); return function (){ return {}; }; }}}); @@ -34,7 +34,7 @@ EntityDeclarationTest.prototype.testMultipleEntities = function(){ expectAsserts(3); var expect = ['Person', 'Book']; var i=0; - var scope = new nglr.Scope({$datastore:{entity:function(name, init){ + var scope = new Scope({$datastore:{entity:function(name, init){ assertEquals(expect[i], name); i++; return function (){ return {}; }; diff --git a/test/FileControllerTest.js b/test/FileControllerTest.js index ca5925e4..09eb6fc5 100644 --- a/test/FileControllerTest.js +++ b/test/FileControllerTest.js @@ -3,7 +3,7 @@ FileControllerTest = TestCase('FileControllerTest'); FileControllerTest.prototype.testOnSelectUpdateView = function(){ var view = jQuery('<span><a/><span/></span>'); var swf = {}; - var controller = new nglr.FileController(view, null, swf); + var controller = new FileController(view, null, swf); swf.uploadFile = function(path){}; controller._on_select('A', 9, '9 bytes'); assertEquals(view.find('a').text(), "A"); @@ -11,14 +11,14 @@ FileControllerTest.prototype.testOnSelectUpdateView = function(){ }; FileControllerTest.prototype.testUpdateModelView = function(){ - var view = nglr.FileController.template(''); + var view = FileController.template(''); var input = $('<input name="value.input">'); var controller; - var scope = new nglr.Scope({value:{}, $binder:{updateView:function(){ + var scope = new Scope({value:{}, $binder:{updateView:function(){ controller.updateView(scope); }}}); view.data('scope', scope); - controller = new nglr.FileController(view, 'value.input', null, "http://server_base"); + controller = new FileController(view, 'value.input', null, "http://server_base"); var value = '{"text":"A", "size":123, "id":"890"}'; controller._on_uploadCompleteData(value); controller.updateView(scope); @@ -34,7 +34,7 @@ FileControllerTest.prototype.testUpdateModelView = function(){ FileControllerTest.prototype.testFileUpload = function(){ expectAsserts(1); var swf = {}; - var controller = new nglr.FileController(null, null, swf, "http://server_base"); + var controller = new FileController(null, null, swf, "http://server_base"); swf.uploadFile = function(path){ assertEquals("http://server_base/_attachments", path); }; @@ -47,16 +47,16 @@ FileControllerTest.prototype.testFileUploadNoFileIsNoop = function(){ var swf = {uploadFile:function(path){ fail(); }}; - var controller = new nglr.FileController(null, swf); + var controller = new FileController(null, swf); controller.upload("basePath", null); }; FileControllerTest.prototype.testRemoveAttachment = function(){ - var doc = nglr.FileController.template(); + var doc = FileController.template(); var input = $('<input name="file">'); - var scope = new nglr.Scope(); + var scope = new Scope(); input.data('scope', scope); - var controller = new nglr.FileController(doc, 'file', null, null); + var controller = new FileController(doc, 'file', null, null); controller.updateView(scope); assertEquals(false, doc.find('input').attr('checked')); @@ -75,10 +75,10 @@ FileControllerTest.prototype.testRemoveAttachment = function(){ }; FileControllerTest.prototype.testShouldEmptyOutOnUndefined = function () { - var view = nglr.FileController.template('hello'); - var controller = new nglr.FileController(view, 'abc', null, null); + var view = FileController.template('hello'); + var controller = new FileController(view, 'abc', null, null); - var scope = new nglr.Scope(); + var scope = new Scope(); scope.set('abc', {text: 'myname', url: 'myurl', size: 1234}); controller.updateView(scope); diff --git a/test/FiltersTest.js b/test/FiltersTest.js index 8943fdd4..c219f24f 100644 --- a/test/FiltersTest.js +++ b/test/FiltersTest.js @@ -3,7 +3,7 @@ FiltersTest = TestCase('FiltersTest'); FiltersTest.prototype.testCurrency = function(){ var html = $('<span/>'); var context = {element:html[0]}; - var currency = nglr.bind(context, angular.filter.currency); + var currency = bind(context, angular.filter.currency); assertEquals(currency(0), '$0.00'); assertEquals(html.hasClass('ng-format-negative'), false); @@ -15,8 +15,8 @@ FiltersTest.prototype.testCurrency = function(){ FiltersTest.prototype.testFilterThisIsContext = function(){ expectAsserts(2); - var scope = new nglr.Scope(); - nglr.Scope.expressionCache = {}; + var scope = new Scope(); + Scope.expressionCache = {}; var context = {element:123}; angular.filter.testFn = function () { assertEquals('Context not equal', this, context); @@ -28,7 +28,7 @@ FiltersTest.prototype.testFilterThisIsContext = function(){ FiltersTest.prototype.testNumberFormat = function(){ var context = {jqElement:$('<span/>')}; - var number = nglr.bind(context, angular.filter.number); + var number = bind(context, angular.filter.number); assertEquals('0', number(0, 0)); assertEquals('0.00', number(0)); @@ -40,7 +40,7 @@ FiltersTest.prototype.testNumberFormat = function(){ }; FiltersTest.prototype.testJson = function () { - assertEquals(nglr.toJson({a:"b"}, true), angular.filter.json({a:"b"})); + assertEquals(toJson({a:"b"}, true), angular.filter.json({a:"b"})); }; FiltersTest.prototype.testPackageTracking = function () { @@ -48,9 +48,9 @@ FiltersTest.prototype.testPackageTracking = function () { var val = angular.filter.trackPackage(trackingNo, title); assertNotNull("Did Not Match: " + trackingNo, val); assertEquals(angular.filter.Meta.TAG, val.TAG); - assertEquals(title + ": " + nglr.trim(trackingNo), val.text); + assertEquals(title + ": " + trim(trackingNo), val.text); assertNotNull(val.url); - assertEquals(nglr.trim(trackingNo), val.trackingNo); + assertEquals(trim(trackingNo), val.trackingNo); assertEquals('<a href="' + val.url + '">' + val.text + '</a>', val.html); }; assert('UPS', ' 1Z 999 999 99 9999 999 9 '); @@ -83,7 +83,7 @@ FiltersTest.prototype.testLink = function() { }; FiltersTest.prototype.testBytes = function(){ - var controller = new nglr.FileController(); + var controller = new FileController(); assertEquals(angular.filter.bytes(123), '123 bytes'); assertEquals(angular.filter.bytes(1234), '1.2 KB'); assertEquals(angular.filter.bytes(1234567), '1.1 MB'); diff --git a/test/JsonTest.js b/test/JsonTest.js index 5c3644f5..cf49bec3 100644 --- a/test/JsonTest.js +++ b/test/JsonTest.js @@ -1,69 +1,69 @@ JsonTest = TestCase("JsonTest"); JsonTest.prototype.testPrimitives = function () { - assertEquals("null", nglr.toJson(0/0)); - assertEquals("null", nglr.toJson(null)); - assertEquals("true", nglr.toJson(true)); - assertEquals("false", nglr.toJson(false)); - assertEquals("123.45", nglr.toJson(123.45)); - assertEquals('"abc"', nglr.toJson("abc")); - assertEquals('"a \\t \\n \\r b \\\\"', nglr.toJson("a \t \n \r b \\")); + assertEquals("null", toJson(0/0)); + assertEquals("null", toJson(null)); + assertEquals("true", toJson(true)); + assertEquals("false", toJson(false)); + assertEquals("123.45", toJson(123.45)); + assertEquals('"abc"', toJson("abc")); + assertEquals('"a \\t \\n \\r b \\\\"', toJson("a \t \n \r b \\")); }; JsonTest.prototype.testEscaping = function () { - assertEquals("\"7\\\\\\\"7\"", nglr.toJson("7\\\"7")); + assertEquals("\"7\\\\\\\"7\"", toJson("7\\\"7")); }; JsonTest.prototype.testObjects = function () { - assertEquals('{"a":1,"b":2}', nglr.toJson({a:1,b:2})); - assertEquals('{"a":{"b":2}}', nglr.toJson({a:{b:2}})); - assertEquals('{"a":{"b":{"c":0}}}', nglr.toJson({a:{b:{c:0}}})); - assertEquals('{"a":{"b":null}}', nglr.toJson({a:{b:0/0}})); + assertEquals('{"a":1,"b":2}', toJson({a:1,b:2})); + assertEquals('{"a":{"b":2}}', toJson({a:{b:2}})); + assertEquals('{"a":{"b":{"c":0}}}', toJson({a:{b:{c:0}}})); + assertEquals('{"a":{"b":null}}', toJson({a:{b:0/0}})); }; JsonTest.prototype.testObjectPretty = function () { - assertEquals('{\n "a":1,\n "b":2}', nglr.toJson({a:1,b:2}, true)); - assertEquals('{\n "a":{\n "b":2}}', nglr.toJson({a:{b:2}}, true)); + assertEquals('{\n "a":1,\n "b":2}', toJson({a:1,b:2}, true)); + assertEquals('{\n "a":{\n "b":2}}', toJson({a:{b:2}}, true)); }; JsonTest.prototype.testArray = function () { - assertEquals('[]', nglr.toJson([])); - assertEquals('[1,"b"]', nglr.toJson([1,"b"])); + assertEquals('[]', toJson([])); + assertEquals('[1,"b"]', toJson([1,"b"])); }; JsonTest.prototype.testIgnoreFunctions = function () { - assertEquals('[null,1]', nglr.toJson([function(){},1])); - assertEquals('{}', nglr.toJson({a:function(){}})); + assertEquals('[null,1]', toJson([function(){},1])); + assertEquals('{}', toJson({a:function(){}})); }; JsonTest.prototype.testParseNull = function () { - assertNull(nglr.fromJson("null")); + assertNull(fromJson("null")); }; JsonTest.prototype.testParseBoolean = function () { - assertTrue(nglr.fromJson("true")); - assertFalse(nglr.fromJson("false")); + assertTrue(fromJson("true")); + assertFalse(fromJson("false")); }; JsonTest.prototype.test$$isIgnored = function () { - assertEquals("{}", nglr.toJson({$$:0})); + assertEquals("{}", toJson({$$:0})); }; JsonTest.prototype.testArrayWithEmptyItems = function () { var a = []; a[1] = "X"; - assertEquals('[null,"X"]', nglr.toJson(a)); + assertEquals('[null,"X"]', toJson(a)); }; JsonTest.prototype.testItShouldEscapeUnicode = function () { assertEquals(1, "\u00a0".length); - assertEquals(8, nglr.toJson("\u00a0").length); - assertEquals(1, nglr.fromJson(nglr.toJson("\u00a0")).length); + assertEquals(8, toJson("\u00a0").length); + assertEquals(1, fromJson(toJson("\u00a0")).length); }; JsonTest.prototype.testItShouldUTCDates = function() { var date = angular.String.toDate("2009-10-09T01:02:03Z"); - assertEquals('"2009-10-09T01:02:03Z"', nglr.toJson(date)); + assertEquals('"2009-10-09T01:02:03Z"', toJson(date)); assertEquals(date.getTime(), - nglr.fromJson('"2009-10-09T01:02:03Z"').getTime()); + fromJson('"2009-10-09T01:02:03Z"').getTime()); }; diff --git a/test/LoaderTest.js b/test/LoaderTest.js index 91a804a5..88ae3efa 100644 --- a/test/LoaderTest.js +++ b/test/LoaderTest.js @@ -3,7 +3,7 @@ LoaderTest = TestCase('LoaderTest'); LoaderTest.prototype.testLoadCss = function(){ if ($.browser.safari) return; var head = jQuery('<head/>')[0]; - var loader = new nglr.Loader(document, head, {}); + var loader = new Loader(document, head, {}); var log = ''; loader.config.server = 'http://'; loader.loadCss('x'); @@ -11,15 +11,15 @@ LoaderTest.prototype.testLoadCss = function(){ }; LoaderTest.prototype.testDefaultDatabasePathFromSubdomain = function() { - var loader = new nglr.Loader(null, null, {server:"http://account.getangular.com", database:"database"}); + var loader = new Loader(null, null, {server:"http://account.getangular.com", database:"database"}); loader.computeConfiguration(); assertEquals("database", loader.config.database); - loader = new nglr.Loader(null, null, {server:"http://account.getangular.com"}); + loader = new Loader(null, null, {server:"http://account.getangular.com"}); loader.computeConfiguration(); assertEquals("account", loader.config.database); - loader = new nglr.Loader(null, null, {server:"https://account.getangular.com"}); + loader = new Loader(null, null, {server:"https://account.getangular.com"}); loader.computeConfiguration(); assertEquals("account", loader.config.database); }; @@ -31,7 +31,7 @@ UrlWatcherTest = TestCase('UrlWatcherTest'); UrlWatcherTest.prototype.testUrlWatcher = function () { expectAsserts(2); var location = {href:"http://server", hash:""}; - var watcher = new nglr.UrlWatcher(location); + var watcher = new UrlWatcher(location); watcher.delay = 1; watcher.listener = function(url){ assertEquals('http://getangular.test', url); @@ -49,9 +49,9 @@ UrlWatcherTest.prototype.testUrlWatcher = function () { UrlWatcherTest.prototype.testItShouldFireOnUpdateEventWhenSpecialURLSet = function(){ expectAsserts(2); var location = {href:"http://server", hash:"#$iframe_notify=1234"}; - var watcher = new nglr.UrlWatcher(location); - nglr._iframe_notify_1234 = function () { - assertEquals("undefined", typeof nglr._iframe_notify_1234); + var watcher = new UrlWatcher(location); + callbacks._iframe_notify_1234 = function () { + assertEquals("undefined", typeof callbacks._iframe_notify_1234); assertEquals("http://server2#", location.href); }; watcher.delay = 1; @@ -66,5 +66,5 @@ UrlWatcherTest.prototype.testItShouldFireOnUpdateEventWhenSpecialURLSet = functi FunctionTest = TestCase("FunctionTest"); FunctionTest.prototype.testEscapeHtml = function () { - assertEquals("<div>&amp;</div>", nglr.escapeHtml('<div>&</div>')); + assertEquals("<div>&amp;</div>", escapeHtml('<div>&</div>')); };
\ No newline at end of file diff --git a/test/ModelTest.js b/test/ModelTest.js index 5d9119a1..dbd97778 100644 --- a/test/ModelTest.js +++ b/test/ModelTest.js @@ -1,7 +1,7 @@ ModelTest = TestCase('ModelTest'); ModelTest.prototype.testLoadSaveOperations = function(){ - var m1 = new nglr.DataStore().entity('A')(); + var m1 = new DataStore().entity('A')(); m1.a = 1; var m2 = {b:1}; @@ -13,7 +13,7 @@ ModelTest.prototype.testLoadSaveOperations = function(){ }; ModelTest.prototype.testLoadfromDoesNotClobberFunctions = function(){ - var m1 = new nglr.DataStore().entity('A')(); + var m1 = new DataStore().entity('A')(); m1.id = function(){return 'OK';}; m1.$loadFrom({id:null}); assertEquals(m1.id(), 'OK'); @@ -24,7 +24,7 @@ ModelTest.prototype.testLoadfromDoesNotClobberFunctions = function(){ }; ModelTest.prototype.testDataStoreDoesNotGetClobbered = function(){ - var ds = new nglr.DataStore(); + var ds = new DataStore(); var m = ds.entity('A')(); assertTrue(m.$$entity.datastore === ds); m.$loadFrom({}); @@ -33,7 +33,7 @@ ModelTest.prototype.testDataStoreDoesNotGetClobbered = function(){ ModelTest.prototype.testManagedModelDelegatesMethodsToDataStore = function(){ expectAsserts(7); - var datastore = new nglr.DataStore(); + var datastore = new DataStore(); var model = datastore.entity("A", {a:1})(); var fn = {}; datastore.save = function(instance, callback) { @@ -56,7 +56,7 @@ ModelTest.prototype.testManagedModelDelegatesMethodsToDataStore = function(){ ModelTest.prototype.testManagedModelCanBeForcedToFlush = function(){ expectAsserts(6); - var datastore = new nglr.DataStore(); + var datastore = new DataStore(); var model = datastore.entity("A", {a:1})(); datastore.save = function(instance, callback) { @@ -77,7 +77,7 @@ ModelTest.prototype.testManagedModelCanBeForcedToFlush = function(){ ModelTest.prototype.testItShouldMakeDeepCopyOfInitialValues = function (){ var initial = {a:[]}; - var entity = new nglr.DataStore().entity("A", initial); + var entity = new DataStore().entity("A", initial); var model = entity(); model.a.push(1); assertEquals(0, entity().a.length); diff --git a/test/ParserTest.js b/test/ParserTest.js index 7fe8e6a4..058010f3 100644 --- a/test/ParserTest.js +++ b/test/ParserTest.js @@ -1,7 +1,7 @@ LexerTest = TestCase('LexerTest'); LexerTest.prototype.testTokenizeAString = function(){ - var lexer = new nglr.Lexer("a.bc[22]+1.3|f:'a\\\'c':\"d\\\"e\""); + var lexer = new Lexer("a.bc[22]+1.3|f:'a\\\'c':\"d\\\"e\""); var tokens = lexer.parse(); var i = 0; assertEquals(tokens[i].index, 0); @@ -54,7 +54,7 @@ LexerTest.prototype.testTokenizeAString = function(){ LexerTest.prototype.testTokenizeRegExp = function(){ - var lexer = new nglr.Lexer("/r 1/"); + var lexer = new Lexer("/r 1/"); var tokens = lexer.parse(); var i = 0; assertEquals(tokens[i].index, 0); @@ -64,7 +64,7 @@ LexerTest.prototype.testTokenizeRegExp = function(){ LexerTest.prototype.testQuotedString = function(){ var str = "['\\'', \"\\\"\"]"; - var lexer = new nglr.Lexer(str); + var lexer = new Lexer(str); var tokens = lexer.parse(); assertEquals(1, tokens[1].index); @@ -77,21 +77,21 @@ LexerTest.prototype.testQuotedString = function(){ LexerTest.prototype.testQuotedStringEscape = function(){ var str = '"\\"\\n\\f\\r\\t\\v\\u00A0"'; - var lexer = new nglr.Lexer(str); + var lexer = new Lexer(str); var tokens = lexer.parse(); assertEquals('"\n\f\r\t\v\u00A0', tokens[0].text); }; LexerTest.prototype.testTokenizeUnicode = function(){ - var lexer = new nglr.Lexer('"\\u00A0"'); + var lexer = new Lexer('"\\u00A0"'); var tokens = lexer.parse(); assertEquals(1, tokens.length); assertEquals('\u00a0', tokens[0].text); }; LexerTest.prototype.testTokenizeRegExpWithOptions = function(){ - var lexer = new nglr.Lexer("/r/g"); + var lexer = new Lexer("/r/g"); var tokens = lexer.parse(); var i = 0; assertEquals(tokens[i].index, 0); @@ -101,7 +101,7 @@ LexerTest.prototype.testTokenizeRegExpWithOptions = function(){ }; LexerTest.prototype.testTokenizeRegExpWithEscape = function(){ - var lexer = new nglr.Lexer("/\\/\\d/"); + var lexer = new Lexer("/\\/\\d/"); var tokens = lexer.parse(); var i = 0; assertEquals(tokens[i].index, 0); @@ -110,14 +110,14 @@ LexerTest.prototype.testTokenizeRegExpWithEscape = function(){ }; LexerTest.prototype.testIgnoreWhitespace = function(){ - var lexer = new nglr.Lexer("a \t \n \r b"); + var lexer = new Lexer("a \t \n \r b"); var tokens = lexer.parse(); assertEquals(tokens[0].text, 'a'); assertEquals(tokens[1].text, 'b'); }; LexerTest.prototype.testRelation = function(){ - var lexer = new nglr.Lexer("! == != < > <= >="); + var lexer = new Lexer("! == != < > <= >="); var tokens = lexer.parse(); assertEquals(tokens[0].text, '!'); assertEquals(tokens[1].text, '=='); @@ -129,7 +129,7 @@ LexerTest.prototype.testRelation = function(){ }; LexerTest.prototype.testStatements = function(){ - var lexer = new nglr.Lexer("a;b;"); + var lexer = new Lexer("a;b;"); var tokens = lexer.parse(); assertEquals(tokens[0].text, 'a'); assertEquals(tokens[1].text, ';'); @@ -140,7 +140,7 @@ LexerTest.prototype.testStatements = function(){ ParserTest = TestCase('ParserTest'); ParserTest.prototype.testExpressions = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); assertEquals(scope.eval("-1"), -1); assertEquals(scope.eval("1 + 2.5"), 3.5); assertEquals(scope.eval("1 + -2.5"), -1.5); @@ -151,7 +151,7 @@ ParserTest.prototype.testExpressions = function(){ }; ParserTest.prototype.testComparison = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); assertEquals(scope.eval("false"), false); assertEquals(scope.eval("!true"), false); assertEquals(scope.eval("1==1"), true); @@ -163,14 +163,14 @@ ParserTest.prototype.testComparison = function(){ }; ParserTest.prototype.testLogical = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); assertEquals(scope.eval("0&&2"), 0&&2); assertEquals(scope.eval("0||2"), 0||2); assertEquals(scope.eval("0||1&&2"), 0||1&&2); }; ParserTest.prototype.testString = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); assertEquals(scope.eval("'a' + 'b c'"), "ab c"); }; @@ -182,7 +182,7 @@ ParserTest.prototype.testFilters = function(){ angular.filter.upper = {_case:function(input) { return input.toUpperCase(); }}; - var scope = new nglr.Scope(); + var scope = new Scope(); try { scope.eval("1|nonExistant"); fail(); @@ -196,7 +196,7 @@ ParserTest.prototype.testFilters = function(){ }; ParserTest.prototype.testScopeAccess = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); scope.set('a', 123); scope.set('b.c', 456); assertEquals(scope.eval("a", scope), 123); @@ -205,16 +205,16 @@ ParserTest.prototype.testScopeAccess = function(){ }; ParserTest.prototype.testGrouping = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); assertEquals(scope.eval("(1+2)*3"), (1+2)*3); }; ParserTest.prototype.testAssignments = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); assertEquals(scope.eval("a=12"), 12); assertEquals(scope.get("a"), 12); - scope = new nglr.Scope(); + scope = new Scope(); assertEquals(scope.eval("x.y.z=123;"), 123); assertEquals(scope.get("x.y.z"), 123); @@ -224,13 +224,13 @@ ParserTest.prototype.testAssignments = function(){ }; ParserTest.prototype.testFunctionCallsNoArgs = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); scope.set('const', function(a,b){return 123;}); assertEquals(scope.eval("const()"), 123); }; ParserTest.prototype.testFunctionCalls = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); scope.set('add', function(a,b){ return a+b; }); @@ -238,7 +238,7 @@ ParserTest.prototype.testFunctionCalls = function(){ }; ParserTest.prototype.testCalculationBug = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); scope.set('taxRate', 8); scope.set('subTotal', 100); assertEquals(scope.eval("taxRate / 100 * subTotal"), 8); @@ -246,7 +246,7 @@ ParserTest.prototype.testCalculationBug = function(){ }; ParserTest.prototype.testArray = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); assertEquals(scope.eval("[]").length, 0); assertEquals(scope.eval("[1, 2]").length, 2); assertEquals(scope.eval("[1, 2]")[0], 1); @@ -254,7 +254,7 @@ ParserTest.prototype.testArray = function(){ }; ParserTest.prototype.testArrayAccess = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); assertEquals(scope.eval("[1][0]"), 1); assertEquals(scope.eval("[[1]][0][0]"), 1); assertEquals(scope.eval("[].length"), 0); @@ -262,33 +262,33 @@ ParserTest.prototype.testArrayAccess = function(){ }; ParserTest.prototype.testObject = function(){ - var scope = new nglr.Scope(); - assertEquals(nglr.toJson(scope.eval("{}")), "{}"); - assertEquals(nglr.toJson(scope.eval("{a:'b'}")), '{"a":"b"}'); - assertEquals(nglr.toJson(scope.eval("{'a':'b'}")), '{"a":"b"}'); - assertEquals(nglr.toJson(scope.eval("{\"a\":'b'}")), '{"a":"b"}'); + var scope = new Scope(); + assertEquals(toJson(scope.eval("{}")), "{}"); + assertEquals(toJson(scope.eval("{a:'b'}")), '{"a":"b"}'); + assertEquals(toJson(scope.eval("{'a':'b'}")), '{"a":"b"}'); + assertEquals(toJson(scope.eval("{\"a\":'b'}")), '{"a":"b"}'); }; ParserTest.prototype.testObjectAccess = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); assertEquals("WC", scope.eval("{false:'WC', true:'CC'}[false]")); }; ParserTest.prototype.testJSON = function(){ - var scope = new nglr.Scope(); - assertEquals(nglr.toJson(scope.eval("[{}]")), "[{}]"); - assertEquals(nglr.toJson(scope.eval("[{a:[]}, {b:1}]")), '[{"a":[]},{"b":1}]'); + var scope = new Scope(); + assertEquals(toJson(scope.eval("[{}]")), "[{}]"); + assertEquals(toJson(scope.eval("[{a:[]}, {b:1}]")), '[{"a":[]},{"b":1}]'); }; ParserTest.prototype.testMultippleStatements = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); assertEquals(scope.eval("a=1;b=3;a+b"), 4); assertEquals(scope.eval(";;1;;"), 1); }; ParserTest.prototype.testParseThrow = function(){ expectAsserts(1); - var scope = new nglr.Scope(); + var scope = new Scope(); scope.set('e', 'abc'); try { scope.eval("throw e"); @@ -298,7 +298,7 @@ ParserTest.prototype.testParseThrow = function(){ }; ParserTest.prototype.testMethodsGetDispatchedWithCorrectThis = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); var C = function (){ this.a=123; }; @@ -310,7 +310,7 @@ ParserTest.prototype.testMethodsGetDispatchedWithCorrectThis = function(){ assertEquals(123, scope.eval("obj.getA()")); }; ParserTest.prototype.testMethodsArgumentsGetCorrectThis = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); var C = function (){ this.a=123; }; @@ -326,13 +326,13 @@ ParserTest.prototype.testMethodsArgumentsGetCorrectThis = function(){ }; ParserTest.prototype.testObjectPointsToScopeValue = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); scope.set('a', "abc"); assertEquals("abc", scope.eval("{a:a}").a); }; ParserTest.prototype.testFieldAccess = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); var fn = function(){ return {name:'misko'}; }; @@ -341,14 +341,14 @@ ParserTest.prototype.testFieldAccess = function(){ }; ParserTest.prototype.testArrayIndexBug = function () { - var scope = new nglr.Scope(); + var scope = new Scope(); scope.set('items', [{}, {name:'misko'}]); assertEquals("misko", scope.eval('items[1].name')); }; ParserTest.prototype.testArrayAssignment = function () { - var scope = new nglr.Scope(); + var scope = new Scope(); scope.set('items', []); assertEquals("abc", scope.eval('items[1] = "abc"')); @@ -359,30 +359,30 @@ ParserTest.prototype.testArrayAssignment = function () { }; ParserTest.prototype.testFiltersCanBeGrouped = function () { - var scope = new nglr.Scope({name:'MISKO'}); + var scope = new Scope({name:'MISKO'}); assertEquals('misko', scope.eval('n = (name|lowercase)')); assertEquals('misko', scope.eval('n')); }; ParserTest.prototype.testFiltersCanBeGrouped = function () { - var scope = new nglr.Scope({name:'MISKO'}); + var scope = new Scope({name:'MISKO'}); assertEquals('misko', scope.eval('n = (name|lowercase)')); assertEquals('misko', scope.eval('n')); }; ParserTest.prototype.testRemainder = function () { - var scope = new nglr.Scope(); + var scope = new Scope(); assertEquals(1, scope.eval('1%2')); }; ParserTest.prototype.testSumOfUndefinedIsNotUndefined = function () { - var scope = new nglr.Scope(); + var scope = new Scope(); assertEquals(1, scope.eval('1+undefined')); assertEquals(1, scope.eval('undefined+1')); }; ParserTest.prototype.testMissingThrowsError = function() { - var scope = new nglr.Scope(); + var scope = new Scope(); try { scope.eval('[].count('); fail(); @@ -392,7 +392,7 @@ ParserTest.prototype.testMissingThrowsError = function() { }; ParserTest.prototype.testItShouldParseOnChangeIntoHashSet = function () { - var scope = new nglr.Scope({count:0}); + var scope = new Scope({count:0}); scope.watch("$anchor.a:count=count+1;$anchor.a:count=count+20;b:count=count+300"); scope.watchListeners["$anchor.a"].listeners[0](); @@ -403,7 +403,7 @@ ParserTest.prototype.testItShouldParseOnChangeIntoHashSet = function () { assertEquals(321, scope.get("count")); }; ParserTest.prototype.testItShouldParseOnChangeBlockIntoHashSet = function () { - var scope = new nglr.Scope({count:0}); + var scope = new Scope({count:0}); var listeners = {a:[], b:[]}; scope.watch("a:{count=count+1;count=count+20;};b:count=count+300", function(n, fn){listeners[n].push(fn);}); @@ -417,12 +417,12 @@ ParserTest.prototype.testItShouldParseOnChangeBlockIntoHashSet = function () { }; ParserTest.prototype.testItShouldParseEmptyOnChangeAsNoop = function () { - var scope = new nglr.Scope(); + var scope = new Scope(); scope.watch("", function(){fail();}); }; ParserTest.prototype.testItShouldCreateClosureFunctionWithNoArguments = function () { - var scope = new nglr.Scope(); + var scope = new Scope(); var fn = scope.eval("{:value}"); scope.set("value", 1); assertEquals(1, fn()); @@ -433,7 +433,7 @@ ParserTest.prototype.testItShouldCreateClosureFunctionWithNoArguments = function }; ParserTest.prototype.testItShouldCreateClosureFunctionWithArguments = function () { - var scope = new nglr.Scope(); + var scope = new Scope(); var fn = scope.eval("{(a):value+a}"); scope.set("value", 1); assertEquals(11, fn(10)); @@ -444,14 +444,14 @@ ParserTest.prototype.testItShouldCreateClosureFunctionWithArguments = function ( }; ParserTest.prototype.testItShouldHaveDefaultArugument = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); var fn = scope.eval("{:$*2}"); assertEquals(4, fn(2)); }; ParserTest.prototype.testReturnFunctionsAreNotBound = function(){ - var scope = new nglr.Scope(); - scope.set("$datastore", new nglr.DataStore()); + var scope = new Scope(); + scope.set("$datastore", new DataStore()); scope.entity("Group"); var Group = scope.get("Group"); assertEquals("eval Group", "function", typeof scope.eval("Group")); diff --git a/test/ScopeTest.js b/test/ScopeTest.js index c66a2329..e1c5c8ce 100644 --- a/test/ScopeTest.js +++ b/test/ScopeTest.js @@ -23,13 +23,13 @@ ScopeTest.prototype.testNoScopeDoesNotCauseInfiniteRecursion = function(){ }; ScopeTest.prototype.testScopeEval = function(){ - var scope = new nglr.Scope({b:345}); + var scope = new Scope({b:345}); assertEquals(scope.eval('b = 123'), 123); assertEquals(scope.get('b'), 123); }; ScopeTest.prototype.testScopeFromPrototype = function(){ - var scope = new nglr.Scope({b:123}); + var scope = new Scope({b:123}); scope.eval('a = b'); scope.eval('b = 456'); assertEquals(scope.get('a'), 123); @@ -37,32 +37,32 @@ ScopeTest.prototype.testScopeFromPrototype = function(){ }; ScopeTest.prototype.testSetScopeGet = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); scope.set('a', 987); assertEquals(scope.get('a'), 987); assertEquals(scope.eval('a'), 987); }; ScopeTest.prototype.testGetChain = function(){ - var scope = new nglr.Scope({a:{b:987}}); + var scope = new Scope({a:{b:987}}); assertEquals(scope.get('a.b'), 987); assertEquals(scope.eval('a.b'), 987); }; ScopeTest.prototype.testGetUndefinedChain = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); assertEquals(typeof scope.get('a.b'), 'undefined'); }; ScopeTest.prototype.testSetChain = function(){ - var scope = new nglr.Scope({a:{}}); + var scope = new Scope({a:{}}); scope.set('a.b', 987); assertEquals(scope.get('a.b'), 987); assertEquals(scope.eval('a.b'), 987); }; ScopeTest.prototype.testSetGetOnChain = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); scope.set('a.b', 987); assertEquals(scope.get('a.b'), 987); assertEquals(scope.eval('a.b'), 987); @@ -70,7 +70,7 @@ ScopeTest.prototype.testSetGetOnChain = function(){ ScopeTest.prototype.testGlobalFunctionAccess =function(){ window['scopeAddTest'] = function (a, b) {return a+b;}; - var scope = new nglr.Scope({window:window}); + var scope = new Scope({window:window}); assertEquals(scope.eval('window.scopeAddTest(1,2)'), 3); scope.set('add', function (a, b) {return a+b;}); @@ -82,7 +82,7 @@ ScopeTest.prototype.testGlobalFunctionAccess =function(){ ScopeTest.prototype.testValidationEval = function(){ expectAsserts(4); - var scope = new nglr.Scope(); + var scope = new Scope(); angular.validator.testValidator = function(value, expect){ assertEquals(scope, this.scope); return value == expect ? null : "Error text"; @@ -96,7 +96,7 @@ ScopeTest.prototype.testValidationEval = function(){ ScopeTest.prototype.testCallingNonExistantMethodShouldProduceFriendlyException = function() { expectAsserts(1); - var scope = new nglr.Scope({obj:{}}); + var scope = new Scope({obj:{}}); try { scope.eval("obj.iDontExist()"); fail(); @@ -106,7 +106,7 @@ ScopeTest.prototype.testCallingNonExistantMethodShouldProduceFriendlyException = }; ScopeTest.prototype.testAccessingWithInvalidPathShouldThrowError = function() { - var scope = new nglr.Scope(); + var scope = new Scope(); try { scope.get('a.{{b}}'); fail(); @@ -116,25 +116,25 @@ ScopeTest.prototype.testAccessingWithInvalidPathShouldThrowError = function() { }; ScopeTest.prototype.testItShouldHave$parent = function() { - var parent = new nglr.Scope({}, "ROOT"); - var child = new nglr.Scope(parent.state); + var parent = new Scope({}, "ROOT"); + var child = new Scope(parent.state); assertSame("parent", child.state.$parent, parent.state); assertSame("root", child.state.$root, parent.state); }; ScopeTest.prototype.testItShouldHave$root = function() { - var scope = new nglr.Scope({}, "ROOT"); + var scope = new Scope({}, "ROOT"); assertSame(scope.state.$root, scope.state); }; ScopeTest.prototype.testItShouldBuildPathOnUndefined = function(){ - var scope = new nglr.Scope({}, "ROOT"); + var scope = new Scope({}, "ROOT"); scope.setEval("a.$b.c", 1); assertJsonEquals({$b:{c:1}}, scope.get("a")); }; ScopeTest.prototype.testItShouldMapUnderscoreFunctions = function(){ - var scope = new nglr.Scope({}, "ROOT"); + var scope = new Scope({}, "ROOT"); scope.set("a", [1,2,3]); assertEquals('function', typeof scope.get("a.$size")); scope.eval("a.$includeIf(4,true)"); diff --git a/test/ServerTest.js b/test/ServerTest.js index d1f662f9..e367c90a 100644 --- a/test/ServerTest.js +++ b/test/ServerTest.js @@ -1,7 +1,7 @@ ServerTest = TestCase("ServerTest"); ServerTest.prototype.testBreakLargeRequestIntoPackets = function() { var log = ""; - var server = new nglr.Server("http://server", function(url){ + var server = new Server("http://server", function(url){ log += "|" + url; }); server.maxSize = 30; @@ -10,7 +10,7 @@ ServerTest.prototype.testBreakLargeRequestIntoPackets = function() { assertEquals(200, code); assertEquals("response", r); }); - nglr.uuid0("response"); + callbacks.uuid0("response"); assertEquals( "|http://server/$/uuid0/2/1?h=eyJtIjoiUE9TVCIsInAiOnt9LCJ1Ij" + "|http://server/$/uuid0/2/2?h=oiL2RhdGEvZGF0YWJhc2UifQ==", @@ -18,7 +18,7 @@ ServerTest.prototype.testBreakLargeRequestIntoPackets = function() { }; ServerTest.prototype.testItShouldEncodeUsingUrlRules = function() { - var server = new nglr.Server("http://server"); + var server = new Server("http://server"); assertEquals("fn5-fn5-", server.base64url("~~~~~~")); assertEquals("fn5_fn5_", server.base64url("~~\u007f~~\u007f")); }; @@ -28,13 +28,13 @@ FrameServerTest = TestCase("FrameServerTest"); FrameServerTest.prototype = { testRead:function(){ var window = {name:'$DATASET:"MyData"'}; - var server = new nglr.FrameServer(window); + var server = new FrameServer(window); server.read(); assertEquals("MyData", server.data); }, testWrite:function(){ var window = {}; - var server = new nglr.FrameServer(window); + var server = new FrameServer(window); server.data = "TestData" server.write(); assertEquals('$DATASET:"TestData"', window.name); diff --git a/test/UsersTest.js b/test/UsersTest.js index c808885c..f0ff545a 100644 --- a/test/UsersTest.js +++ b/test/UsersTest.js @@ -10,10 +10,10 @@ UsersTest.prototype = { testItShouldFetchCurrentUser:function(){ expectAsserts(5); var user; - var users = new nglr.Users({request:function(method, url, request, callback){ + var users = new Users({request:function(method, url, request, callback){ assertEquals("GET", method); assertEquals("/account.json", url); - assertEquals("{}", nglr.toJson(request)); + assertEquals("{}", toJson(request)); callback(200, {$status_code:200, user:{name:'misko'}}); }}); users.fetchCurrentUser(function(u){ diff --git a/test/WidgetsTest.js b/test/WidgetsTest.js index a245abda..fe20e664 100644 --- a/test/WidgetsTest.js +++ b/test/WidgetsTest.js @@ -2,8 +2,8 @@ WidgetTest = TestCase('WidgetTest'); WidgetTest.prototype.testRequired = function () { var view = $('<input name="a" ng-required>'); - var scope = new nglr.Scope({$invalidWidgets:[]}); - var cntl = new nglr.TextController(view[0], 'a'); + var scope = new Scope({$invalidWidgets:[]}); + var cntl = new TextController(view[0], 'a'); cntl.updateView(scope); assertTrue(view.hasClass('ng-validation-error')); assertEquals("Required Value", view.attr('ng-error')); @@ -15,8 +15,8 @@ WidgetTest.prototype.testRequired = function () { WidgetTest.prototype.testValidator = function () { var view = $('<input name="a" ng-validate="testValidator:\'ABC\'">'); - var scope = new nglr.Scope({$invalidWidgets:[]}); - var cntl = new nglr.TextController(view[0], 'a'); + var scope = new Scope({$invalidWidgets:[]}); + var cntl = new TextController(view[0], 'a'); angular.validator.testValidator = function(value, expect){ return value == expect ? null : "Error text"; }; @@ -43,8 +43,8 @@ WidgetTest.prototype.testValidator = function () { WidgetTest.prototype.testRequiredValidator = function () { var view = $('<input name="a" ng-required ng-validate="testValidator:\'ABC\'">'); - var scope = new nglr.Scope({$invalidWidgets:[]}); - var cntl = new nglr.TextController(view[0], 'a'); + var scope = new Scope({$invalidWidgets:[]}); + var cntl = new TextController(view[0], 'a'); angular.validator.testValidator = function(value, expect){ return value == expect ? null : "Error text"; }; @@ -67,29 +67,29 @@ WidgetTest.prototype.testRequiredValidator = function () { delete angular.validator['testValidator']; }; -TextController = TestCase("TextController"); +TextControllerTest = TestCase("TextControllerTest"); -TextController.prototype.testDatePicker = function() { +TextControllerTest.prototype.testDatePicker = function() { var input = $('<input type="text" ng-widget="datepicker">'); - input.data('scope', new nglr.Scope()); + input.data('scope', new Scope()); var body = $(document.body); body.append(input); - var binder = new nglr.Binder(input[0], new nglr.WidgetFactory()); + var binder = new Binder(input[0], new WidgetFactory()); assertTrue('before', input.data('datepicker') === undefined); binder.compile(); assertTrue('after', input.data('datepicker') !== null); assertTrue(body.html(), input.hasClass('hasDatepicker')); }; -RepeaterUpdater = TestCase("RepeaterUpdater"); +RepeaterUpdaterTest = TestCase("RepeaterUpdaterTest"); -RepeaterUpdater.prototype.testRemoveThenAdd = function() { +RepeaterUpdaterTest.prototype.testRemoveThenAdd = function() { var view = $("<div><span/></div>"); var template = function () { return $("<li/>"); }; - var repeater = new nglr.RepeaterUpdater(view.find("span"), "a in b", template, ""); - var scope = new nglr.Scope(); + var repeater = new RepeaterUpdater(view.find("span"), "a in b", template, ""); + var scope = new Scope(); scope.set('b', [1,2]); repeater.updateView(scope); @@ -102,14 +102,14 @@ RepeaterUpdater.prototype.testRemoveThenAdd = function() { assertEquals(1, view.find("li").size()); }; -RepeaterUpdater.prototype.testShouldBindWidgetOnRepeaterClone = function(){ +RepeaterUpdaterTest.prototype.testShouldBindWidgetOnRepeaterClone = function(){ //fail(); }; -RepeaterUpdater.prototype.testShouldThrowInformativeSyntaxError= function(){ +RepeaterUpdaterTest.prototype.testShouldThrowInformativeSyntaxError= function(){ expectAsserts(1); try { - var repeater = new nglr.RepeaterUpdater(null, "a=b"); + var repeater = new RepeaterUpdater(null, "a=b"); } catch (e) { assertEquals("Expected ng-repeat in form of 'item in collection' but got 'a=b'.", e); } @@ -118,17 +118,17 @@ RepeaterUpdater.prototype.testShouldThrowInformativeSyntaxError= function(){ SelectControllerTest = TestCase("SelectControllerTest"); SelectControllerTest.prototype.testShouldUpdateModelNullOnNothingSelected = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); var view = {selectedIndex:-1, options:[]}; - var cntl = new nglr.SelectController(view, 'abc'); + var cntl = new SelectController(view, 'abc'); cntl.updateModel(scope); assertNull(scope.get('abc')); }; SelectControllerTest.prototype.testShouldUpdateModelWhenNothingSelected = function(){ - var scope = new nglr.Scope(); + var scope = new Scope(); var view = {value:'123'}; - var cntl = new nglr.SelectController(view, 'abc'); + var cntl = new SelectController(view, 'abc'); cntl.updateView(scope); assertEquals("123", scope.get('abc')); }; @@ -137,8 +137,8 @@ BindUpdaterTest = TestCase("BindUpdaterTest"); BindUpdaterTest.prototype.testShouldDisplayNothingForUndefined = function () { var view = $('<span />'); - var controller = new nglr.BindUpdater(view[0], "{{a}}"); - var scope = new nglr.Scope(); + var controller = new BindUpdater(view[0], "{{a}}"); + var scope = new Scope(); scope.set('a', undefined); controller.updateView(scope); @@ -151,20 +151,20 @@ BindUpdaterTest.prototype.testShouldDisplayNothingForUndefined = function () { BindUpdaterTest.prototype.testShouldDisplayJsonForNonStrings = function () { var view = $('<span />'); - var controller = new nglr.BindUpdater(view[0], "{{obj}}"); + var controller = new BindUpdater(view[0], "{{obj}}"); - controller.updateView(new nglr.Scope({obj:[]})); + controller.updateView(new Scope({obj:[]})); assertEquals("[]", view.text()); - controller.updateView(new nglr.Scope({obj:{text:'abc'}})); - assertEquals('abc', nglr.fromJson(view.text()).text); + controller.updateView(new Scope({obj:{text:'abc'}})); + assertEquals('abc', fromJson(view.text()).text); }; BindUpdaterTest.prototype.testShouldInsertHtmlNode = function () { var view = $('<span />'); - var controller = new nglr.BindUpdater(view[0], "<fake>&{{obj}}</fake>"); - var scope = new nglr.Scope(); + var controller = new BindUpdater(view[0], "<fake>&{{obj}}</fake>"); + var scope = new Scope(); scope.set("obj", $('<div>myDiv</div>')[0]); controller.updateView(scope); @@ -174,8 +174,8 @@ BindUpdaterTest.prototype.testShouldInsertHtmlNode = function () { BindUpdaterTest.prototype.testShouldDisplayTextMethod = function () { var view = $('<div />'); - var controller = new nglr.BindUpdater(view[0], "{{obj}}"); - var scope = new nglr.Scope(); + var controller = new BindUpdater(view[0], "{{obj}}"); + var scope = new Scope(); scope.set("obj", new angular.filter.Meta({text:function(){return "abc";}})); controller.updateView(scope); @@ -187,13 +187,13 @@ BindUpdaterTest.prototype.testShouldDisplayTextMethod = function () { scope.set("obj", {text:"123"}); controller.updateView(scope); - assertEquals("123", nglr.fromJson(view.text()).text); + assertEquals("123", fromJson(view.text()).text); }; BindUpdaterTest.prototype.testShouldDisplayHtmlMethod = function () { var view = $('<div />'); - var controller = new nglr.BindUpdater(view[0], "{{obj}}"); - var scope = new nglr.Scope(); + var controller = new BindUpdater(view[0], "{{obj}}"); + var scope = new Scope(); scope.set("obj", new angular.filter.Meta({html:function(){return "a<div>b</div>c";}})); controller.updateView(scope); @@ -205,13 +205,13 @@ BindUpdaterTest.prototype.testShouldDisplayHtmlMethod = function () { scope.set("obj", {html:"123"}); controller.updateView(scope); - assertEquals("123", nglr.fromJson(view.text()).html); + assertEquals("123", fromJson(view.text()).html); }; BindUpdaterTest.prototype.testUdateBoolean = function() { var view = $('<div />'); - var controller = new nglr.BindUpdater(view[0], "{{true}}, {{false}}"); - controller.updateView(new nglr.Scope()); + var controller = new BindUpdater(view[0], "{{true}}, {{false}}"); + controller.updateView(new Scope()); assertEquals('true, false', view.text()); }; @@ -219,9 +219,9 @@ BindAttrUpdaterTest = TestCase("BindAttrUpdaterTest"); BindAttrUpdaterTest.prototype.testShouldLoadBlankImageWhenBindingIsUndefined = function () { var view = $('<img />'); - var controller = new nglr.BindAttrUpdater(view[0], {src: '{{imageUrl}}'}); + var controller = new BindAttrUpdater(view[0], {src: '{{imageUrl}}'}); - var scope = new nglr.Scope(); + var scope = new Scope(); scope.set('imageUrl', undefined); scope.set('config.server', 'http://server'); @@ -229,16 +229,15 @@ BindAttrUpdaterTest.prototype.testShouldLoadBlankImageWhenBindingIsUndefined = f assertEquals("http://server/images/blank.gif", view.attr('src')); }; -RepeaterUpdaterTest = TestCase("RepeaterUpdaterTest"); RepeaterUpdaterTest.prototype.testShouldNotDieWhenRepeatExpressionIsNull = function() { - var rep = new nglr.RepeaterUpdater(null, "$item in items", null, null); - var scope = new nglr.Scope(); + var rep = new RepeaterUpdater(null, "$item in items", null, null); + var scope = new Scope(); scope.set('items', undefined); rep.updateView(scope); }; RepeaterUpdaterTest.prototype.testShouldIterateOverKeys = function() { - var rep = new nglr.RepeaterUpdater(null, "($k,_v) in items", null, null); + var rep = new RepeaterUpdater(null, "($k,_v) in items", null, null); assertEquals("items", rep.iteratorExp); assertEquals("_v", rep.valueExp); assertEquals("$k", rep.keyExp); @@ -247,14 +246,14 @@ RepeaterUpdaterTest.prototype.testShouldIterateOverKeys = function() { EvalUpdaterTest = TestCase("EvalUpdaterTest"); EvalUpdaterTest.prototype.testEvalThrowsException = function(){ var view = $('<div/>'); - var eval = new nglr.EvalUpdater(view[0], 'undefined()'); + var eval = new EvalUpdater(view[0], 'undefined()'); - eval.updateView(new nglr.Scope()); + eval.updateView(new Scope()); assertTrue(!!view.attr('ng-error')); assertTrue(view.hasClass('ng-exception')); eval.exp = "1"; - eval.updateView(new nglr.Scope()); + eval.updateView(new Scope()); assertFalse(!!view.attr('ng-error')); assertFalse(view.hasClass('ng-exception')); }; @@ -262,8 +261,8 @@ EvalUpdaterTest.prototype.testEvalThrowsException = function(){ RadioControllerTest = TestCase("RadioController"); RadioControllerTest.prototype.testItShouldTreatTrueStringAsBoolean = function () { var view = $('<input type="radio" name="select" value="true"/>'); - var radio = new nglr.RadioController(view[0], 'select'); - var scope = new nglr.Scope({select:true}); + var radio = new RadioController(view[0], 'select'); + var scope = new Scope({select:true}); radio.updateView(scope); assertTrue(view[0].checked); }; diff --git a/test/XSitePostTest.js b/test/XSitePostTest.js deleted file mode 100644 index 8a3e4d6f..00000000 --- a/test/XSitePostTest.js +++ /dev/null @@ -1,47 +0,0 @@ -XSitePost = TestCase("XSitePost"); - -var e = function(text){ return Base64.encode(text); }; - -XSitePost.prototype.testMessageReceived = function () { - expectAsserts(4); - var xPost = new nglr.XSitePost(); - xPost.baseUrl = "http://getangular.test"; - xPost.post = function(url, request, callback){ - assertEquals('http://getangular.test/url', url); - assertEquals('abc', request.a); - assertEquals('xyz', request.x); - }; - xPost.incomingFragment('#id;0;1;'+e('/url')+':a:'+e('abc')+':x:'+e('xyz')); - assertEquals('{}', nglr.toJson(xPost.inQueue)); -}; - -XSitePost.prototype.testMessageReceivedInParts = function () { - expectAsserts(5); - var xPost = new nglr.XSitePost(); - xPost.baseUrl = "http://getangular.test"; - xPost.post = function(url, request, callback){ - assertEquals('http://getangular.test/url', url); - assertEquals('abc', request.a); - assertEquals('xyz', request.x); - }; - xPost.incomingFragment('#id;1;2;:x:'+e('xyz')); - assertNotSame('{}', nglr.toJson(xPost.inQueue)); - xPost.incomingFragment('#id;0;2;'+e('/url')+':a:'+e('abc')); - assertEquals('{}', nglr.toJson(xPost.inQueue)); -}; - -XSitePost.prototype.testPostResponsIsEnqueued = function () { - var xPost = new nglr.XSitePost(); - xPost.maxMsgSize = 11; - xPost.response("id", "response", "status"); - - assertEquals('["id:0:2:cmVzcG9uc2U","id:1:2:="]', - nglr.toJson(xPost.outQueue)); -}; - -XSitePost.prototype.testPush = function () { - var window = {}; - var xPost = new nglr.XSitePost(window); - xPost.response("id", "response", "status"); - assertEquals('id:0:1:cmVzcG9uc2U=', xPost.outQueue[0]); -}; diff --git a/test/formsTest.js b/test/formsTest.js index 66c4ec69..ccade915 100644 --- a/test/formsTest.js +++ b/test/formsTest.js @@ -2,7 +2,7 @@ nglrTest = TestCase('nglrTest'); nglrTest.prototype.testShiftBind = function(){ expectAsserts(3); - nglr.shiftBind('this', function(target, arg) { + shiftBind('this', function(target, arg) { assertEquals(this, 'this'); assertEquals(target, 'target'); assertEquals(arg, 'arg'); @@ -11,7 +11,7 @@ nglrTest.prototype.testShiftBind = function(){ nglrTest.prototype.testBind = function(){ expectAsserts(2); - nglr.bind('this', function(arg) { + bind('this', function(arg) { assertEquals(this, 'this'); assertEquals(arg, 'arg'); }).apply('XXX', ['arg']); diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index 13378d36..dde21846 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -6,8 +6,8 @@ HIDDEN = jQuery.browser.msie ? ' style="display: none; "' : ' style="display: none;"'; -nglr.msie = jQuery.browser.msie; -nglr.alert = function(msg) {jstestdriver.console.log("ALERT: " + msg);}; +msie = jQuery.browser.msie; +alert = function(msg) {jstestdriver.console.log("ALERT: " + msg);}; function noop(){} @@ -50,7 +50,7 @@ jQuery.fn.sortedHtml = function() { var toString = function(index, node) { node = node || this; if (node.nodeName == "#text") { - html += nglr.escapeHtml(node.nodeValue); + html += escapeHtml(node.nodeValue); } else { html += '<' + node.nodeName.toLowerCase(); var attributes = node.attributes || []; @@ -89,14 +89,14 @@ jQuery.fn.sortedHtml = function() { }; function encode64(obj){ - return Base64.encode(nglr.toJson(obj)); + return Base64.encode(toJson(obj)); } function decode64(base64){ - return nglr.fromJson(Base64.decode(base64)); + return fromJson(Base64.decode(base64)); } -nglr.Loader.prototype.configureJQueryPlugins(); +Loader.prototype.configureJQueryPlugins(); function assertHidden(node) { var display = node.css('display'); @@ -110,7 +110,7 @@ function assertVisible(node) { } function assertJsonEquals(expected, actual) { - assertEquals(nglr.toJson(expected), nglr.toJson(actual)); + assertEquals(toJson(expected), toJson(actual)); } function assertUndefined(value) { @@ -118,7 +118,7 @@ function assertUndefined(value) { } function assertDefined(value) { - assertTrue(nglr.toJson(value), !!value); + assertTrue(toJson(value), !!value); } function assertThrows(error, fn){ |
