From 8f9bf37bcf38165e89f37c147f9315cb8e72fc1f Mon Sep 17 00:00:00 2001 From: Rob Spies Date: Tue, 22 Jun 2010 17:11:57 -0700 Subject: asdsad --- test/ResourceSpec.js | 5 ----- 1 file changed, 5 deletions(-) (limited to 'test') diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js index d11c3e08..4ab3537c 100644 --- a/test/ResourceSpec.js +++ b/test/ResourceSpec.js @@ -35,11 +35,6 @@ describe("resource", function() { var item = LineItem.get({id:456}); xhr.flush(); nakedExpect(item).toEqual({id:'abc'}); - - item = LineItem.get({id:456}); - xhr.flush(); - nakedExpect(item).toEqual({id:'abc'}); - }); it("should create resource", function(){ -- cgit v1.2.3 From 1f0562150921ea2f05149b64ef0440937491def9 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 2 Jul 2010 15:39:47 -0700 Subject: change all attributes from ng- to ng: prefix --- test/BinderTest.js | 148 +++++++++++++++++++------------------- test/ScenarioSpec.js | 2 +- test/delete/WidgetsTest.js | 2 +- test/directivesSpec.js | 90 +++++++++++------------ test/markupSpec.js | 10 +-- test/moveToAngularCom/miscTest.js | 6 +- test/testabilityPatch.js | 4 +- test/widgetsSpec.js | 8 +-- 8 files changed, 135 insertions(+), 135 deletions(-) (limited to 'test') diff --git a/test/BinderTest.js b/test/BinderTest.js index ecdd506f..6dc47cce 100644 --- a/test/BinderTest.js +++ b/test/BinderTest.js @@ -47,7 +47,7 @@ BinderTest.prototype.testChangingCheckboxUpdatesModel = function(){ }; BinderTest.prototype.testBindUpdate = function() { - var c = this.compile('
'); + var c = this.compile('
'); assertEquals(123, c.scope.$get('a')); }; @@ -71,26 +71,26 @@ BinderTest.prototype.testChangingSelectSelectedUpdatesModel = function(){ }; BinderTest.prototype.testExecuteInitialization = function() { - var c = this.compile('
'); + var c = this.compile('
'); assertEquals(c.scope.$get('a'), 123); }; BinderTest.prototype.testExecuteInitializationStatements = function() { - var c = this.compile('
'); + var c = this.compile('
'); assertEquals(c.scope.$get('a'), 123); assertEquals(c.scope.$get('b'), 345); }; BinderTest.prototype.testApplyTextBindings = function(){ - var form = this.compile('
x
'); + var form = this.compile('
x
'); form.scope.$set('model', {a:123}); form.scope.$eval(); assertEquals('123', form.node.text()); }; BinderTest.prototype.testReplaceBindingInTextWithSpan = function() { - assertEquals(this.compileToHtml("a{{b}}c"), 'ac'); - assertEquals(this.compileToHtml("{{b}}"), ''); + assertEquals(this.compileToHtml("a{{b}}c"), 'ac'); + assertEquals(this.compileToHtml("{{b}}"), ''); }; BinderTest.prototype.testBindingSpaceConfusesIE = function() { @@ -99,16 +99,16 @@ BinderTest.prototype.testBindingSpaceConfusesIE = function() { span.innerHTML = ' '; var nbsp = span.firstChild.nodeValue; assertEquals( - ''+nbsp+'', + ''+nbsp+'', this.compileToHtml("{{a}} {{b}}")); assertEquals( - ''+nbsp+'x '+nbsp+'()', + ''+nbsp+'x '+nbsp+'()', this.compileToHtml("{{A}} x {{B}} ({{C}})")); }; BinderTest.prototype.testBindingOfAttributes = function() { var c = this.compile(""); - var attrbinding = c.node.attr("ng-bind-attr"); + var attrbinding = c.node.attr("ng:bind-attr"); var bindings = fromJson(attrbinding); assertEquals("http://s/a{{b}}c", decodeURI(bindings.href)); assertTrue(!bindings.foo); @@ -116,7 +116,7 @@ BinderTest.prototype.testBindingOfAttributes = function() { BinderTest.prototype.testMarkMultipleAttributes = function() { var c = this.compile(''); - var attrbinding = c.node.attr("ng-bind-attr"); + var attrbinding = c.node.attr("ng:bind-attr"); var bindings = fromJson(attrbinding); assertEquals(bindings.foo, "{{d}}"); assertEquals(decodeURI(bindings.href), "http://s/a{{b}}c"); @@ -126,17 +126,17 @@ BinderTest.prototype.testAttributesNoneBound = function() { var c = this.compile(""); var a = c.node; assertEquals(a[0].nodeName, "A"); - assertTrue(!a.attr("ng-bind-attr")); + assertTrue(!a.attr("ng:bind-attr")); }; BinderTest.prototype.testExistingAttrbindingIsAppended = function() { - var c = this.compile(""); + var c = this.compile(""); var a = c.node; - assertEquals('{"b":"{{def}}","href":"http://s/{{abc}}"}', a.attr('ng-bind-attr')); + assertEquals('{"b":"{{def}}","href":"http://s/{{abc}}"}', a.attr('ng:bind-attr')); }; BinderTest.prototype.testAttributesAreEvaluated = function(){ - var c = this.compile(''); + var c = this.compile(''); var binder = c.binder, form = c.node; c.scope.$eval('a=1;b=2'); c.scope.$eval(); @@ -147,7 +147,7 @@ BinderTest.prototype.testAttributesAreEvaluated = function(){ BinderTest.prototype.testInputTypeButtonActionExecutesInScope = function(){ var savedCalled = false; - var c = this.compile(''); + var c = this.compile(''); c.scope.$set("person.save", function(){ savedCalled = true; }); @@ -157,7 +157,7 @@ BinderTest.prototype.testInputTypeButtonActionExecutesInScope = function(){ BinderTest.prototype.testInputTypeButtonActionExecutesInScope2 = function(){ var log = ""; - var c = this.compile(''); + var c = this.compile(''); c.scope.$set("action", function(){ log += 'click;'; }); @@ -168,7 +168,7 @@ BinderTest.prototype.testInputTypeButtonActionExecutesInScope2 = function(){ BinderTest.prototype.testButtonElementActionExecutesInScope = function(){ var savedCalled = false; - var c = this.compile(''); + var c = this.compile(''); c.scope.$set("person.save", function(){ savedCalled = true; }); @@ -177,7 +177,7 @@ BinderTest.prototype.testButtonElementActionExecutesInScope = function(){ }; BinderTest.prototype.testRepeaterUpdateBindings = function(){ - var a = this.compile('
'); + var a = this.compile('
'); var form = a.node; var items = [{a:"A"}, {a:"B"}]; a.scope.$set('model', {items:items}); @@ -185,25 +185,25 @@ BinderTest.prototype.testRepeaterUpdateBindings = function(){ a.scope.$eval(); assertEquals('
    ' + '<#comment>' + - '
  • A
  • ' + - '
  • B
  • ' + + '
  • A
  • ' + + '
  • B
  • ' + '
', sortedHtml(form)); items.unshift({a:'C'}); a.scope.$eval(); assertEquals('
    ' + '<#comment>' + - '
  • C
  • ' + - '
  • A
  • ' + - '
  • B
  • ' + + '
  • C
  • ' + + '
  • A
  • ' + + '
  • B
  • ' + '
', sortedHtml(form)); items.shift(); a.scope.$eval(); assertEquals('
    ' + '<#comment>' + - '
  • A
  • ' + - '
  • B
  • ' + + '
  • A
  • ' + + '
  • B
  • ' + '
', sortedHtml(form)); items.shift(); @@ -212,19 +212,19 @@ BinderTest.prototype.testRepeaterUpdateBindings = function(){ }; BinderTest.prototype.testRepeaterContentDoesNotBind = function(){ - var a = this.compile('
'); + var a = this.compile('
'); a.scope.$set('model', {items:[{a:"A"}]}); a.scope.$eval(); assertEquals('
    ' + '<#comment>' + - '
  • A
  • ' + + '
  • A
  • ' + '
', sortedHtml(a.node)); }; BinderTest.prototype.testExpandEntityTag = function(){ assertEquals( - '
', - this.compileToHtml('
')); + '
', + this.compileToHtml('
')); }; BinderTest.prototype.testDoNotOverwriteCustomAction = function(){ @@ -233,7 +233,7 @@ BinderTest.prototype.testDoNotOverwriteCustomAction = function(){ }; BinderTest.prototype.testRepeaterAdd = function(){ - var c = this.compile('
'); + var c = this.compile('
'); var doc = c.node; c.scope.$set('items', [{x:'a'}, {x:'b'}]); c.scope.$eval(); @@ -248,7 +248,7 @@ BinderTest.prototype.testRepeaterAdd = function(){ }; BinderTest.prototype.testItShouldRemoveExtraChildrenWhenIteratingOverHash = function(){ - var c = this.compile('
{{i}}
'); + var c = this.compile('
{{i}}
'); var items = {}; c.scope.$set("items", items); @@ -308,8 +308,8 @@ BinderTest.prototype.testIfAttrBindingThrowsErrorDecorateTheAttribute = function }; BinderTest.prototype.testNestedRepeater = function() { - var a = this.compile('
' + - '
    ' + + var a = this.compile('
    ' + + '
      ' + '
      '); a.scope.$set('model', [{name:'a', item:['a1', 'a2']}, {name:'b', item:['b1', 'b2']}]); @@ -317,20 +317,20 @@ BinderTest.prototype.testNestedRepeater = function() { assertEquals('
      '+ '<#comment>'+ - '
      '+ + '
      '+ '<#comment>'+ - '
        '+ - '
          '+ + '
            '+ + '
              '+ '
              '+ - '
              '+ + '
              '+ '<#comment>'+ - '
                '+ - '
                  '+ + '
                    '+ + '
                      '+ '
                      ', sortedHtml(a.node)); }; BinderTest.prototype.testHideBindingExpression = function() { - var a = this.compile('
                      '); + var a = this.compile('
                      '); a.scope.$set('hidden', 3); a.scope.$eval(); @@ -344,7 +344,7 @@ BinderTest.prototype.testHideBindingExpression = function() { }; BinderTest.prototype.testHideBinding = function() { - var c = this.compile('
                      '); + var c = this.compile('
                      '); c.scope.$set('hidden', 'true'); c.scope.$eval(); @@ -363,7 +363,7 @@ BinderTest.prototype.testHideBinding = function() { }; BinderTest.prototype.testShowBinding = function() { - var c = this.compile('
                      '); + var c = this.compile('
                      '); c.scope.$set('show', 'true'); c.scope.$eval(); @@ -382,42 +382,42 @@ BinderTest.prototype.testShowBinding = function() { }; BinderTest.prototype.testBindClassUndefined = function() { - var doc = this.compile('
                      '); + var doc = this.compile('
                      '); doc.scope.$eval(); assertEquals( - '
                      ', + '
                      ', sortedHtml(doc.node)); }; BinderTest.prototype.testBindClass = function() { - var c = this.compile('
                      '); + var c = this.compile('
                      '); c.scope.$set('class', 'testClass'); c.scope.$eval(); assertEquals(sortedHtml(c.node), - '
                      '); + '
                      '); c.scope.$set('class', ['a', 'b']); c.scope.$eval(); assertEquals(sortedHtml(c.node), - '
                      '); + '
                      '); }; BinderTest.prototype.testBindClassEvenOdd = function() { - var x = this.compile('
                      '); + var x = this.compile('
                      '); x.scope.$eval(); assertEquals( '
                      <#comment>' + - '
                      ' + - '
                      ', + '
                      ' + + '
                      ', sortedHtml(x.node)); }; BinderTest.prototype.testBindStyle = function() { - var c = this.compile('
                      '); + var c = this.compile('
                      '); c.scope.$eval('style={color:"red"}'); c.scope.$eval(); @@ -430,7 +430,7 @@ BinderTest.prototype.testBindStyle = function() { BinderTest.prototype.testActionOnAHrefThrowsError = function(){ var model = {books:[]}; - var c = this.compile('Add Phone', model); + var c = this.compile('Add Phone', model); c.scope.action = function(){ throw {a:'abc', b:2}; }; @@ -450,23 +450,23 @@ BinderTest.prototype.testActionOnAHrefThrowsError = function(){ BinderTest.prototype.testShoulIgnoreVbNonBindable = function(){ var c = this.compile("
                      {{a}}" + - "
                      {{a}}
                      " + - "
                      {{b}}
                      " + - "
                      {{c}}
                      "); + "
                      {{a}}
                      " + + "
                      {{b}}
                      " + + "
                      {{c}}
                      "); c.scope.$set('a', 123); c.scope.$eval(); assertEquals('123{{a}}{{b}}{{c}}', c.node.text()); }; BinderTest.prototype.testOptionShouldUpdateParentToGetProperBinding = function() { - var c = this.compile(''); + var c = this.compile(''); c.scope.$set('s', 1); c.scope.$eval(); assertEquals(1, c.node[0].selectedIndex); }; BinderTest.prototype.testRepeaterShouldBindInputsDefaults = function () { - var c = this.compile('
                      '); + var c = this.compile('
                      '); c.scope.$set('items', [{}, {name:'misko'}]); c.scope.$eval(); @@ -475,7 +475,7 @@ BinderTest.prototype.testRepeaterShouldBindInputsDefaults = function () { }; BinderTest.prototype.testRepeaterShouldCreateArray = function () { - var c = this.compile(''); + var c = this.compile(''); c.scope.$eval(); assertEquals(0, c.scope.$get('items').length); @@ -486,7 +486,7 @@ BinderTest.prototype.testShouldTemplateBindPreElements = function () { c.scope.$set("name", "World"); c.scope.$eval(); - assertEquals('
                      Hello World!
                      ', sortedHtml(c.node)); + assertEquals('
                      Hello World!
                      ', sortedHtml(c.node)); }; BinderTest.prototype.testFillInOptionValueWhenMissing = function() { @@ -511,7 +511,7 @@ BinderTest.prototype.testFillInOptionValueWhenMissing = function() { BinderTest.prototype.testValidateForm = function() { var c = this.compile('
                      ' + - '
                      '); + '
                      '); var items = [{}, {}]; c.scope.$set("items", items); c.scope.$eval(); @@ -539,7 +539,7 @@ BinderTest.prototype.testValidateForm = function() { }; BinderTest.prototype.testValidateOnlyVisibleItems = function(){ - var c = this.compile('
                      '); + var c = this.compile('
                      '); jqLite(document.body).append(c.node); c.scope.$set("show", true); c.scope.$eval(); @@ -552,9 +552,9 @@ BinderTest.prototype.testValidateOnlyVisibleItems = function(){ BinderTest.prototype.testDeleteAttributeIfEvaluatesFalse = function() { var c = this.compile('
                      ' + - '' + - '' + - '
                      '); + '' + + '' + + '
                      '); c.scope.$eval(); function assertChild(index, disabled) { var child = childNode(c.node, index); @@ -571,8 +571,8 @@ BinderTest.prototype.testDeleteAttributeIfEvaluatesFalse = function() { BinderTest.prototype.testItShouldDisplayErrorWhenActionIsSyntacticlyIncorect = function(){ var c = this.compile('
                      ' + - '' + - '
                      '); + '' + + '
                      '); var first = jqLite(c.node[0].childNodes[0]); var second = jqLite(c.node[0].childNodes[1]); @@ -605,8 +605,8 @@ BinderTest.prototype.testItShouldSelectTheCorrectRadioBox = function() { BinderTest.prototype.testItShouldListenOnRightScope = function() { var c = this.compile( - '
                        ' + - '
                      '); + '
                        ' + + '
                      '); c.scope.$eval(); assertEquals(0, c.scope.$get("counter")); assertEquals(0, c.scope.$get("gCounter")); @@ -618,25 +618,25 @@ BinderTest.prototype.testItShouldListenOnRightScope = function() { }; BinderTest.prototype.testItShouldRepeatOnHashes = function() { - var x = this.compile('
                      '); + var x = this.compile('
                      '); x.scope.$eval(); assertEquals('
                        ' + '<#comment>' + - '
                      • a0
                      • ' + - '
                      • b1
                      • ' + + '
                      • a0
                      • ' + + '
                      • b1
                      • ' + '
                      ', sortedHtml(x.node)); }; BinderTest.prototype.testItShouldFireChangeListenersBeforeUpdate = function(){ - var x = this.compile('
                      '); + var x = this.compile('
                      '); x.scope.$set("name", ""); x.scope.$watch("watched", "name=123"); x.scope.$set("watched", "change"); x.scope.$eval(); assertEquals(123, x.scope.$get("name")); assertEquals( - '
                      123
                      ', + '
                      123
                      ', sortedHtml(x.node)); }; @@ -657,7 +657,7 @@ BinderTest.prototype.XtestItShouldRenderMultiRootHtmlInBinding = function() { x.scope.a = "acd"; x.scope.$eval(); assertEquals( - '
                      before acdafter
                      ', + '
                      before acdafter
                      ', sortedHtml(x.node)); }; diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js index 9afe8e95..7ea3192d 100644 --- a/test/ScenarioSpec.js +++ b/test/ScenarioSpec.js @@ -1,6 +1,6 @@ describe("ScenarioSpec: Compilation", function(){ it("should compile dom node and return scope", function(){ - var node = jqLite('
                      {{b=a+1}}
                      ')[0]; + var node = jqLite('
                      {{b=a+1}}
                      ')[0]; var scope = compile(node); scope.$init(); expect(scope.a).toEqual(1); diff --git a/test/delete/WidgetsTest.js b/test/delete/WidgetsTest.js index 313d7372..9acc6126 100644 --- a/test/delete/WidgetsTest.js +++ b/test/delete/WidgetsTest.js @@ -111,7 +111,7 @@ RepeaterUpdaterTest.prototype.testShouldThrowInformativeSyntaxError= function(){ try { var repeater = new RepeaterUpdater(null, "a=b"); } catch (e) { - assertEquals("Expected ng-repeat in form of 'item in collection' but got 'a=b'.", e); + assertEquals("Expected ng:repeat in form of 'item in collection' but got 'a=b'.", e); } }; diff --git a/test/directivesSpec.js b/test/directivesSpec.js index 42869a05..836c51e8 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -17,57 +17,57 @@ describe("directives", function(){ expect(size(jqCache)).toEqual(0); }); - it("should ng-init", function() { - var scope = compile('
                      '); + it("should ng:init", function() { + var scope = compile('
                      '); expect(scope.a).toEqual(123); }); - it("should ng-eval", function() { - var scope = compile('
                      '); + it("should ng:eval", function() { + var scope = compile('
                      '); expect(scope.a).toEqual(1); scope.$eval(); expect(scope.a).toEqual(2); }); - it('should ng-bind', function() { - var scope = compile('
                      '); + it('should ng:bind', function() { + var scope = compile('
                      '); expect(element.text()).toEqual(''); scope.a = 'misko'; scope.$eval(); expect(element.text()).toEqual('misko'); }); - it('should ng-bind html', function() { - var scope = compile('
                      '); + it('should ng:bind html', function() { + var scope = compile('
                      '); scope.html = '
                      hello
                      '; scope.$eval(); expect(lowercase(element.html())).toEqual('
                      hello
                      '); }); - it('should ng-bind element', function() { + it('should ng:bind element', function() { angularFilter.myElement = function() { return jqLite('hello'); }; - var scope = compile('
                      '); + var scope = compile('
                      '); scope.$eval(); expect(lowercase(element.html())).toEqual('hello'); }); - it('should ng-bind-template', function() { - var scope = compile('
                      '); + it('should ng:bind-template', function() { + var scope = compile('
                      '); scope.$set('name', 'Misko'); scope.$eval(); expect(element.text()).toEqual('Hello Misko!'); }); - it('should ng-bind-attr', function(){ - var scope = compile(''); + it('should ng:bind-attr', function(){ + var scope = compile(''); expect(element.attr('src')).toEqual('http://localhost/mysrc'); expect(element.attr('alt')).toEqual('myalt'); }); it('should remove special attributes on false', function(){ - var scope = compile(''); + var scope = compile(''); var input = scope.$element[0]; expect(input.disabled).toEqual(false); expect(input.readOnly).toEqual(false); @@ -83,15 +83,15 @@ describe("directives", function(){ expect(input.checked).toEqual(true); }); - it('should ng-non-bindable', function(){ - var scope = compile('
                      '); + it('should ng:non-bindable', function(){ + var scope = compile('
                      '); scope.$set('name', 'misko'); scope.$eval(); expect(element.text()).toEqual(''); }); - it('should ng-repeat over array', function(){ - var scope = compile('
                      '); + it('should ng:repeat over array', function(){ + var scope = compile('
                      '); scope.$set('items', ['misko', 'shyam']); scope.$eval(); @@ -106,28 +106,28 @@ describe("directives", function(){ expect(element.text()).toEqual('brad;'); }); - it('should ng-repeat over object', function(){ - var scope = compile('
                      '); + it('should ng:repeat over object', function(){ + var scope = compile('
                      '); scope.$set('items', {misko:'swe', shyam:'set'}); scope.$eval(); expect(element.text()).toEqual('misko:swe;shyam:set;'); }); - it('should set ng-repeat to [] if undefinde', function(){ - var scope = compile('
                      '); + it('should set ng:repeat to [] if undefinde', function(){ + var scope = compile('
                      '); expect(scope.items).toEqual([]); }); - it('should error on wrong parsing of ng-repeat', function(){ - var scope = compile('
                      '); + it('should error on wrong parsing of ng:repeat', function(){ + var scope = compile('
                      '); var log = ""; log += element.attr('ng-exception') + ';'; log += element.hasClass('ng-exception') + ';'; - expect(log).toEqual("\"Expected ng-repeat in form of 'item in collection' but got 'i dont parse'.\";true;"); + expect(log).toEqual("\"Expected ng:repeat in form of 'item in collection' but got 'i dont parse'.\";true;"); }); - it('should ng-watch', function(){ - var scope = compile('
                      '); + it('should ng:watch', function(){ + var scope = compile('
                      '); scope.$eval(); scope.$eval(); expect(scope.$get('count')).toEqual(0); @@ -138,8 +138,8 @@ describe("directives", function(){ expect(scope.$get('count')).toEqual(1); }); - it('should ng-click', function(){ - var scope = compile('
                      '); + it('should ng:click', function(){ + var scope = compile('
                      '); scope.$eval(); expect(scope.$get('clicked')).toBeFalsy(); @@ -147,16 +147,16 @@ describe("directives", function(){ expect(scope.$get('clicked')).toEqual(true); }); - it('should ng-class', function(){ - var scope = compile('
                      '); + it('should ng:class', function(){ + var scope = compile('
                      '); scope.$eval(); expect(element.hasClass('existing')).toBeTruthy(); expect(element.hasClass('A')).toBeTruthy(); expect(element.hasClass('B')).toBeTruthy(); }); - it('should ng-class odd/even', function(){ - var scope = compile('
                        • '); + it('should ng:class odd/even', function(){ + var scope = compile('
                            • '); scope.$eval(); var e1 = jqLite(element[0].childNodes[1]); var e2 = jqLite(element[0].childNodes[2]); @@ -166,14 +166,14 @@ describe("directives", function(){ expect(e2.hasClass('even')).toBeTruthy(); }); - it('should ng-style', function(){ - var scope = compile('
                              '); + it('should ng:style', function(){ + var scope = compile('
                              '); scope.$eval(); expect(element.css('color')).toEqual('red'); }); - it('should ng-show', function(){ - var scope = compile('
                              '); + it('should ng:show', function(){ + var scope = compile('
                              '); scope.$eval(); expect(isCssVisible(scope.$element)).toEqual(true); scope.$set('hide', true); @@ -181,8 +181,8 @@ describe("directives", function(){ expect(isCssVisible(scope.$element)).toEqual(false); }); - it('should ng-hide', function(){ - var scope = compile('
                              '); + it('should ng:hide', function(){ + var scope = compile('
                              '); scope.$eval(); expect(isCssVisible(scope.$element)).toEqual(false); scope.$set('show', true); @@ -190,7 +190,7 @@ describe("directives", function(){ expect(isCssVisible(scope.$element)).toEqual(true); }); - describe('ng-controller', function(){ + describe('ng:controller', function(){ it('should bind', function(){ window.Greeter = function(){ this.greeting = 'hello'; @@ -203,18 +203,18 @@ describe("directives", function(){ return this.greeting + ' ' + name + this.suffix; } }; - var scope = compile('
                              '); + var scope = compile('
                              '); expect(scope.greeting).toEqual('hello'); expect(scope.greet('misko')).toEqual('hello misko!'); window.Greeter = undefined; }); }); - it('should eval things according to ng-eval-order', function(){ + it('should eval things according to ng:eval-order', function(){ var scope = compile( - '
                              ' + + '
                              ' + '{{log = log + \'e\'}}' + - '' + + '' + '{{log = log + \'b\'}}' + '' + '' + diff --git a/test/markupSpec.js b/test/markupSpec.js index 8358b673..5fe5bba9 100644 --- a/test/markupSpec.js +++ b/test/markupSpec.js @@ -20,23 +20,23 @@ describe("markups", function(){ it('should translate {{}} in text', function(){ compile('
                              hello {{name}}!
                              '); - expect(sortedHtml(element)).toEqual('
                              hello !
                              '); + expect(sortedHtml(element)).toEqual('
                              hello !
                              '); scope.$set('name', 'Misko'); scope.$eval(); - expect(sortedHtml(element)).toEqual('
                              hello Misko!
                              '); + expect(sortedHtml(element)).toEqual('
                              hello Misko!
                              '); }); it('should translate {{}} in terminal nodes', function(){ compile(''); - expect(sortedHtml(element).replace(' selected="true"', '')).toEqual(''); + expect(sortedHtml(element).replace(' selected="true"', '')).toEqual(''); scope.$set('name', 'Misko'); scope.$eval(); - expect(sortedHtml(element).replace(' selected="true"', '')).toEqual(''); + expect(sortedHtml(element).replace(' selected="true"', '')).toEqual(''); }); it('should translate {{}} in attributes', function(){ compile(''); - expect(element.attr('ng-bind-attr')).toEqual('{"src":"http://server/{{path}}.png"}'); + expect(element.attr('ng:bind-attr')).toEqual('{"src":"http://server/{{path}}.png"}'); scope.$set('path', 'a/b'); scope.$eval(); expect(element.attr('src')).toEqual("http://server/a/b.png"); diff --git a/test/moveToAngularCom/miscTest.js b/test/moveToAngularCom/miscTest.js index aa0e1186..cc8f1c8c 100644 --- a/test/moveToAngularCom/miscTest.js +++ b/test/moveToAngularCom/miscTest.js @@ -1,7 +1,7 @@ BinderTest.prototype.testExpandEntityTagWithName = function(){ var c = this.compile('
                              '); assertEquals( - '
                              ', + '
                              ', sortedHtml(c.node)); assertEquals("Person", c.scope.$get("friend.$entity")); assertEquals("friend", c.scope.$get("friend.$$anchor")); @@ -10,7 +10,7 @@ BinderTest.prototype.testExpandEntityTagWithName = function(){ BinderTest.prototype.testExpandSubmitButtonToAction = function(){ var html = this.compileToHtml(''); assertTrue(html, html.indexOf('ng-action="$save()"') > 0 ); - assertTrue(html, html.indexOf('ng-bind-attr="{"disabled":"{{$invalidWidgets}}"}"') > 0 ); + assertTrue(html, html.indexOf('ng:bind-attr="{"disabled":"{{$invalidWidgets}}"}"') > 0 ); }; BinderTest.prototype.testReplaceFileUploadWithSwf = function(){ @@ -29,7 +29,7 @@ BinderTest.prototype.testReplaceFileUploadWithSwf = function(){ BinderTest.prototype.testExpandEntityTagWithDefaults = function(){ assertEquals( - '
                              ', + '
                              ', this.compileToHtml('
                              ')); }; diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index d621b1f1..3020dfba 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -65,7 +65,7 @@ function sortedHtml(element) { var attrs = []; for(var i=0; i'); + compile(''); expect(scope.$get('name')).toEqual("Misko"); expect(scope.$get('count')).toEqual(0); @@ -382,7 +382,7 @@ describe("widget", function(){ describe('ng:switch', function(){ it('should switch on value change', function(){ - compile('
                              first:{{name}}
                              second:{{name}}
                              '); + compile('
                              first:{{name}}
                              second:{{name}}
                              '); expect(element.html()).toEqual(''); scope.select = 1; scope.$eval(); @@ -399,7 +399,7 @@ describe("widget", function(){ }); it("should match urls", function(){ - var scope = angular.compile('
                              {{params.name}}
                              '); + var scope = angular.compile('
                              {{params.name}}
                              '); scope.url = '/Book/Moby'; scope.$init(); expect(scope.$element.text()).toEqual('Moby'); @@ -412,7 +412,7 @@ describe("widget", function(){ }); it('should call init on switch', function(){ - var scope = angular.compile('
                              {{name}}
                              '); + var scope = angular.compile('
                              {{name}}
                              '); var cleared = false; scope.url = 'a'; scope.$invalidWidgets = {clearOrphans: function(){ -- cgit v1.2.3 From b5195b8f67b143d6c38de9ae2295cb364fab0d95 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 2 Jul 2010 17:26:26 -0700 Subject: changed the eval for ie to be able to return a function --- test/testabilityPatch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index 3020dfba..b71943f6 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -81,7 +81,7 @@ function sortedHtml(element) { attr.name !='style' && attr.name.substr(0, 6) != 'jQuery') { // in IE we need to check for all of these. - if (!/ng:\d+/.exec(attr.name)) + if (!/ng-\d+/.exec(attr.name)) attrs.push(' ' + attr.name + '="' + attr.value + '"'); } } -- cgit v1.2.3 From ee82dae3186b7a4fc4d339fc97d5792b2b5e2648 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 8 Jul 2010 10:40:54 -0700 Subject: added class as a constant keyword to generated code --- test/BinderTest.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/BinderTest.js b/test/BinderTest.js index 6dc47cce..ef1ef362 100644 --- a/test/BinderTest.js +++ b/test/BinderTest.js @@ -396,14 +396,12 @@ BinderTest.prototype.testBindClass = function() { c.scope.$set('class', 'testClass'); c.scope.$eval(); - assertEquals(sortedHtml(c.node), - '
                              '); + assertEquals('
                              ', sortedHtml(c.node)); c.scope.$set('class', ['a', 'b']); c.scope.$eval(); - assertEquals(sortedHtml(c.node), - '
                              '); + assertEquals('
                              ', sortedHtml(c.node)); }; BinderTest.prototype.testBindClassEvenOdd = function() { -- cgit v1.2.3 From 00bb79039251ca6e4622df677fe4894552774bd5 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 8 Jul 2010 15:55:00 -0700 Subject: fixed IE tests --- test/scenario/RunnerSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/scenario/RunnerSpec.js b/test/scenario/RunnerSpec.js index 884e897a..bbdd9e8c 100644 --- a/test/scenario/RunnerSpec.js +++ b/test/scenario/RunnerSpec.js @@ -163,7 +163,7 @@ describe('Runner', function(){ expect(log).toEqual('first;second;'); next(); expect(log).toEqual('first;second;done;'); - expect(spec).not.toEqual(window); + expect(spec === window).toEqual(false); expect(spec).toEqual(firstThis); expect(spec).toEqual(secondThis); expect(spec).toEqual(doneThis); -- cgit v1.2.3 From 228b54aa2ea9c5faf9280f39317fdf07b2d49580 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 9 Jul 2010 14:45:29 -0700 Subject: ng:repeat ignores prototype keys --- test/directivesSpec.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/directivesSpec.js b/test/directivesSpec.js index 836c51e8..df0b5b94 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -93,15 +93,17 @@ describe("directives", function(){ it('should ng:repeat over array', function(){ var scope = compile('
                              '); - scope.$set('items', ['misko', 'shyam']); + Array.prototype.extraProperty = "should be ignored"; + scope.items = ['misko', 'shyam']; scope.$eval(); expect(element.text()).toEqual('misko;shyam;'); + delete Array.prototype.extraProperty; - scope.$set('items', ['adam', 'kai', 'brad']); + scope.items = ['adam', 'kai', 'brad']; scope.$eval(); expect(element.text()).toEqual('adam;kai;brad;'); - scope.$set('items', ['brad']); + scope.items = ['brad']; scope.$eval(); expect(element.text()).toEqual('brad;'); }); -- cgit v1.2.3 From 87cfc27be331685043ea2a4414eba4fd8fbb4a2c Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 13 Jul 2010 11:20:11 -0700 Subject: changed remaining ng- to ng: --- test/BinderTest.js | 10 +++++----- test/FiltersTest.js | 6 +++--- test/ValidatorsTest.js | 6 +++--- test/delete/WidgetsTest.js | 6 +++--- test/servicesSpec.js | 2 +- test/widgetsSpec.js | 42 +++++++++++++++++++++--------------------- 6 files changed, 36 insertions(+), 36 deletions(-) (limited to 'test') diff --git a/test/BinderTest.js b/test/BinderTest.js index ef1ef362..1b1201fa 100644 --- a/test/BinderTest.js +++ b/test/BinderTest.js @@ -42,7 +42,7 @@ BinderTest.prototype.testChangingRadioUpdatesModel = function(){ }; BinderTest.prototype.testChangingCheckboxUpdatesModel = function(){ - var form = this.compile(''); + var form = this.compile(''); assertEquals(true, form.scope.model.price); }; @@ -508,8 +508,8 @@ BinderTest.prototype.testFillInOptionValueWhenMissing = function() { }; BinderTest.prototype.testValidateForm = function() { - var c = this.compile('
                              ' + - '
                              '); + var c = this.compile('
                              ' + + '
                              '); var items = [{}, {}]; c.scope.$set("items", items); c.scope.$eval(); @@ -537,7 +537,7 @@ BinderTest.prototype.testValidateForm = function() { }; BinderTest.prototype.testValidateOnlyVisibleItems = function(){ - var c = this.compile('
                              '); + var c = this.compile('
                              '); jqLite(document.body).append(c.node); c.scope.$set("show", true); c.scope.$eval(); @@ -660,7 +660,7 @@ BinderTest.prototype.XtestItShouldRenderMultiRootHtmlInBinding = function() { }; BinderTest.prototype.testItShouldUseFormaterForText = function() { - var x = this.compile(''); + var x = this.compile(''); x.scope.$eval(); assertEquals(['a','b'], x.scope.$get('a')); var input = x.node; diff --git a/test/FiltersTest.js b/test/FiltersTest.js index f839bb51..903a7a2f 100644 --- a/test/FiltersTest.js +++ b/test/FiltersTest.js @@ -6,11 +6,11 @@ FiltersTest.prototype.testCurrency = function(){ var currency = bind(context, angular.filter.currency); assertEquals(currency(0), '$0.00'); - assertEquals(html.hasClass('ng-format-negative'), false); + assertEquals(html.hasClass('ng:format-negative'), false); assertEquals(currency(-999), '$-999.00'); - assertEquals(html.hasClass('ng-format-negative'), true); + assertEquals(html.hasClass('ng:format-negative'), true); assertEquals(currency(1234.5678), '$1,234.57'); - assertEquals(html.hasClass('ng-format-negative'), false); + assertEquals(html.hasClass('ng:format-negative'), false); }; FiltersTest.prototype.testFilterThisIsContext = function(){ diff --git a/test/ValidatorsTest.js b/test/ValidatorsTest.js index 573c340d..2e156f84 100644 --- a/test/ValidatorsTest.js +++ b/test/ValidatorsTest.js @@ -7,7 +7,7 @@ ValidatorTest.prototype.testItShouldHaveThisSet = function() { validator.last = last; validator._this = this; }; - var scope = compile(''); + var scope = compile(''); scope.name = 'misko'; scope.$init(); assertEquals('misko', validator.first); @@ -109,7 +109,7 @@ describe('Validator:asynchronous', function(){ it('should make a request and show spinner', function(){ var value, fn; - var scope = compile(''); + var scope = compile(''); scope.$init(); var input = scope.$element; scope.asyncFn = function(v,f){ @@ -151,7 +151,7 @@ describe('Validator:asynchronous', function(){ }); it("should handle update function", function(){ - var scope = angular.compile(''); + var scope = angular.compile(''); scope.asyncFn = jasmine.createSpy(); scope.updateFn = jasmine.createSpy(); scope.name = 'misko'; diff --git a/test/delete/WidgetsTest.js b/test/delete/WidgetsTest.js index 9acc6126..ccc87afd 100644 --- a/test/delete/WidgetsTest.js +++ b/test/delete/WidgetsTest.js @@ -1,7 +1,7 @@ WidgetTest = TestCase('WidgetTest'); WidgetTest.prototype.testRequired = function () { - var view = $(''); + var view = $(''); var scope = new Scope({$invalidWidgets:[]}); var cntl = new TextController(view[0], 'a', angularFormatter.noop); cntl.updateView(scope); @@ -14,7 +14,7 @@ WidgetTest.prototype.testRequired = function () { }; WidgetTest.prototype.testValidator = function () { - var view = $(''); + var view = $(''); var scope = new Scope({$invalidWidgets:[]}); var cntl = new TextController(view[0], 'a', angularFormatter.noop); angular.validator.testValidator = function(value, expect){ @@ -42,7 +42,7 @@ WidgetTest.prototype.testValidator = function () { }; WidgetTest.prototype.testRequiredValidator = function () { - var view = $(''); + var view = $(''); var scope = new Scope({$invalidWidgets:[]}); var cntl = new TextController(view[0], 'a', angularFormatter.noop); angular.validator.testValidator = function(value, expect){ diff --git a/test/servicesSpec.js b/test/servicesSpec.js index f679a39b..32e7812a 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -136,7 +136,7 @@ describe("service", function(){ describe("$invalidWidgets", function(){ it("should count number of invalid widgets", function(){ - var scope = compile('').$init(); + var scope = compile('').$init(); expect(scope.$invalidWidgets.length).toEqual(1); scope.price = 123; scope.$eval(); diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index 158b24a8..1c9e698a 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -41,10 +41,10 @@ describe("widget", function(){ expect(scope.$get('count')).toEqual(2); }); - describe("ng-format", function(){ + describe("ng:format", function(){ it("should format text", function(){ - compile(''); + compile(''); expect(scope.$get('list')).toEqual(['a', 'b', 'c']); scope.$set('list', ['x', 'y', 'z']); @@ -57,7 +57,7 @@ describe("widget", function(){ }); it("should come up blank if null", function(){ - compile('', function(){ + compile('', function(){ scope.age = null; }); expect(scope.age).toBeNull(); @@ -65,7 +65,7 @@ describe("widget", function(){ }); it("should show incorect text while number does not parse", function(){ - compile(''); + compile(''); scope.age = 123; scope.$eval(); scope.$element.val('123X'); @@ -76,14 +76,14 @@ describe("widget", function(){ }); it("should clober incorect text if model changes", function(){ - compile(''); + compile(''); scope.age = 456; scope.$eval(); expect(scope.$element.val()).toEqual('456'); }); it("should not clober text if model changes doe to itself", function(){ - compile(''); + compile(''); scope.$element.val('a '); scope.$element.trigger('change'); @@ -107,7 +107,7 @@ describe("widget", function(){ }); it("should come up blank when no value specifiend", function(){ - compile(''); + compile(''); scope.$eval(); expect(scope.$element.val()).toEqual(''); expect(scope.age).toEqual(null); @@ -134,7 +134,7 @@ describe("widget", function(){ expect(scope.checkbox).toEqual(true); }); - it("should use ng-format", function(){ + it("should use ng:format", function(){ angularFormatter('testFormat', { parse: function(value){ return value ? "Worked" : "Failed"; @@ -146,7 +146,7 @@ describe("widget", function(){ } }); - compile(''); + compile(''); expect(scope.state).toEqual("Worked"); expect(scope.$element[0].checked).toEqual(true); @@ -161,9 +161,9 @@ describe("widget", function(){ }); }); - describe("ng-validate", function(){ - it("should process ng-validate", function(){ - compile(''); + describe("ng:validate", function(){ + it("should process ng:validate", function(){ + compile(''); expect(element.hasClass('ng-validation-error')).toBeTruthy(); expect(element.attr('ng-validation-error')).toEqual('Not a number'); @@ -179,7 +179,7 @@ describe("widget", function(){ }); it('should not blow up for validation with bound attributes', function() { - compile(''); + compile(''); expect(element.hasClass('ng-validation-error')).toBeTruthy(); expect(element.attr('ng-validation-error')).toEqual('Required'); @@ -192,7 +192,7 @@ describe("widget", function(){ it("should not call validator if undefined/empty", function(){ var lastValue = "NOT_CALLED"; angularValidator.myValidator = function(value){lastValue = value;}; - compile(''); + compile(''); expect(lastValue).toEqual("NOT_CALLED"); scope.url = 'http://server'; @@ -205,19 +205,19 @@ describe("widget", function(){ }); it("should ignore disabled widgets", function(){ - compile(''); + compile(''); expect(element.hasClass('ng-validation-error')).toBeFalsy(); expect(element.attr('ng-validation-error')).toBeFalsy(); }); it("should ignore readonly widgets", function(){ - compile(''); + compile(''); expect(element.hasClass('ng-validation-error')).toBeFalsy(); expect(element.attr('ng-validation-error')).toBeFalsy(); }); - it("should process ng-required", function(){ - compile(''); + it("should process ng:required", function(){ + compile(''); expect(element.hasClass('ng-validation-error')).toBeTruthy(); expect(element.attr('ng-validation-error')).toEqual('Required'); @@ -232,8 +232,8 @@ describe("widget", function(){ expect(element.attr('ng-validation-error')).toEqual('Required'); }); - it('should allow conditions on ng-required', function() { - compile(''); + it('should allow conditions on ng:required', function() { + compile(''); scope.$set('ineedz', false); scope.$eval(); expect(element.hasClass('ng-validation-error')).toBeFalsy(); @@ -256,7 +256,7 @@ describe("widget", function(){ expect(element.attr('ng-validation-error')).toBeFalsy(); }); - it("should process ng-required2", function() { + it("should process ng:required2", function() { compile(''); expect(scope.$get('name')).toEqual("Misko"); -- cgit v1.2.3 From 4034a2d1e2efb6c76020273c96c3da5ae146f5ca Mon Sep 17 00:00:00 2001 From: Rob Spies Date: Tue, 13 Jul 2010 14:09:53 -0700 Subject: better naming for our verify cache scheme, and tests. --- test/ResourceSpec.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js index 4ab3537c..18b3979b 100644 --- a/test/ResourceSpec.js +++ b/test/ResourceSpec.js @@ -30,8 +30,7 @@ describe("resource", function() { it("should build resource with default param", function(){ xhr.expectGET('/Order/123/Line/456.visa?minimum=0.05').respond({id:'abc'}); - xhr.expectGET('/Order/123/Line/456.visa?minimum=0.05').respond({id:'ddd'}); - var LineItem = resource.route('/Order/:orderId/Line/:id:verb', {orderId: '123', id: '@id.key', verb:'.visa', minimum:0.05}); + var LineItem = resource.route('/Order/:orderId/Line/:id:verb', {orderId: '123', id: '@id.key', verb:'.visa', minimum:0.05}, {verifyCache: 'blah'}); var item = LineItem.get({id:456}); xhr.flush(); nakedExpect(item).toEqual({id:'abc'}); @@ -136,6 +135,23 @@ describe("resource", function() { expect(person.name).toEqual('misko'); }); + it('should return the same object when verifying the cache', function(){ + var scope = angular.compile('
                              '); + var Person = scope.$resource('/Person/:id', null, {query: {method:'GET', isArray: true, verifyCache: true}}); + scope.$browser.xhr.expectGET('/Person/123').respond('[\n{\nname:\n"misko"\n}\n]'); + var person = Person.query({id:123}); + scope.$browser.xhr.flush(); + expect(person[0].name).toEqual('misko'); + + scope.$browser.xhr.expectGET('/Person/123').respond('[\n{\nname:\n"rob"\n}\n]'); + var person2 = Person.query({id:123}); + expect(person2[0].name).toEqual('misko'); + var person2Cache = person2; + scope.$browser.xhr.flush(); + expect(person2Cache).toEqual(person2); + expect(person2[0].name).toEqual('rob'); + }); + describe('failure mode', function(){ it('should report error when non 200', function(){ xhr.expectGET('/CreditCard/123').respond(500, "Server Error"); -- cgit v1.2.3 From ac3c2736c786abe996acc3d01d857dd5f0b3328a Mon Sep 17 00:00:00 2001 From: Rob Spies Date: Tue, 13 Jul 2010 14:15:01 -0700 Subject: Removes silly test addition. --- test/ResourceSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js index 18b3979b..4882e70e 100644 --- a/test/ResourceSpec.js +++ b/test/ResourceSpec.js @@ -30,7 +30,7 @@ describe("resource", function() { it("should build resource with default param", function(){ xhr.expectGET('/Order/123/Line/456.visa?minimum=0.05').respond({id:'abc'}); - var LineItem = resource.route('/Order/:orderId/Line/:id:verb', {orderId: '123', id: '@id.key', verb:'.visa', minimum:0.05}, {verifyCache: 'blah'}); + var LineItem = resource.route('/Order/:orderId/Line/:id:verb', {orderId: '123', id: '@id.key', verb:'.visa', minimum:0.05}); var item = LineItem.get({id:456}); xhr.flush(); nakedExpect(item).toEqual({id:'abc'}); -- cgit v1.2.3 From 10cd9751ea4c76f5f0ebcd0197054b6ac3be563c Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 13 Jul 2010 15:21:42 -0700 Subject: ng-change ng:change --- test/widgetsSpec.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index 1c9e698a..03f31bfe 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -22,7 +22,7 @@ describe("widget", function(){ describe("text", function(){ it('should input-text auto init and handle keyup/change events', function(){ - compile(''); + compile(''); expect(scope.$get('name')).toEqual("Misko"); expect(scope.$get('count')).toEqual(0); @@ -125,7 +125,7 @@ describe("widget", function(){ }); it('should support type="checkbox"', function(){ - compile(''); + compile(''); expect(scope.checkbox).toEqual(true); click(element); expect(scope.checkbox).toEqual(false); @@ -273,14 +273,14 @@ describe("widget", function(){ expect(scope.$get('name')).toEqual('Kai'); }); - it('should call ng-change on button click', function(){ - compile(''); + it('should call ng:change on button click', function(){ + compile(''); click(element); expect(scope.$get('clicked')).toEqual(true); }); it('should support button alias', function(){ - compile(''); + compile(''); click(element); expect(scope.$get('clicked')).toEqual(true); }); @@ -289,9 +289,9 @@ describe("widget", function(){ it('should support type="radio"', function(){ compile('
                              ' + - '' + - '' + - '' + + '' + + '' + + '' + '
                              '); var a = element[0].childNodes[0]; var b = element[0].childNodes[1]; @@ -373,8 +373,8 @@ describe("widget", function(){ expect(element.hasClass('ng-exception')).toBeTruthy(); }); - it('should report error on ng-change exception', function(){ - compile(''); + it('should report error on ng:change exception', function(){ + compile(''); click(element); expect(element.hasClass('ng-exception')).toBeTruthy(); }); -- cgit v1.2.3 From f084fd37dbc80d9701f417a726b4ac3232039d93 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 13 Jul 2010 15:40:39 -0700 Subject: romeve miscTest --- test/moveToAngularCom/miscTest.js | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 test/moveToAngularCom/miscTest.js (limited to 'test') diff --git a/test/moveToAngularCom/miscTest.js b/test/moveToAngularCom/miscTest.js deleted file mode 100644 index cc8f1c8c..00000000 --- a/test/moveToAngularCom/miscTest.js +++ /dev/null @@ -1,35 +0,0 @@ -BinderTest.prototype.testExpandEntityTagWithName = function(){ - var c = this.compile('
                              '); - assertEquals( - '
                              ', - sortedHtml(c.node)); - assertEquals("Person", c.scope.$get("friend.$entity")); - assertEquals("friend", c.scope.$get("friend.$$anchor")); -}; - -BinderTest.prototype.testExpandSubmitButtonToAction = function(){ - var html = this.compileToHtml(''); - assertTrue(html, html.indexOf('ng-action="$save()"') > 0 ); - assertTrue(html, html.indexOf('ng:bind-attr="{"disabled":"{{$invalidWidgets}}"}"') > 0 ); -}; - -BinderTest.prototype.testReplaceFileUploadWithSwf = function(){ - expectAsserts(1); - var form = jQuery("body").append('
                              '); - form.data('scope', new Scope()); - var factory = {}; - var binder = new Binder(form.get(0), factory, new MockLocation()); - factory.createController = function(node){ - assertEquals(node.attr('type'), 'file'); - return {updateModel:function(){}}; - }; - binder.compile(); - jQuery("#testTag").remove(); -}; - -BinderTest.prototype.testExpandEntityTagWithDefaults = function(){ - assertEquals( - '
                              ', - this.compileToHtml('
                              ')); -}; - -- cgit v1.2.3 From 0a57273f0000421639c926d4d180680e3a64c0f7 Mon Sep 17 00:00:00 2001 From: Kai Compagner Date: Thu, 15 Jul 2010 03:08:55 +0800 Subject: fix undefine style --- test/directivesSpec.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/directivesSpec.js b/test/directivesSpec.js index df0b5b94..ef4814bf 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -174,6 +174,13 @@ describe("directives", function(){ expect(element.css('color')).toEqual('red'); }); + it('should silently ignore undefined ng:style', function() { + var scope = compile('
                              '); + scope.$eval(); + dump(sortedHtml(element)); + expect(element.hasClass('ng-exception')).toBeFalsy(); + }); + it('should ng:show', function(){ var scope = compile('
                              '); scope.$eval(); -- cgit v1.2.3 From e3e9ac86750b20fb8ad6765011e06d569899612d Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 14 Jul 2010 17:07:23 -0700 Subject: ng:style remembers previous style and properly resets to it --- test/directivesSpec.js | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/directivesSpec.js b/test/directivesSpec.js index ef4814bf..8ce949aa 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -168,17 +168,30 @@ describe("directives", function(){ expect(e2.hasClass('even')).toBeTruthy(); }); - it('should ng:style', function(){ - var scope = compile('
                              '); - scope.$eval(); - expect(element.css('color')).toEqual('red'); - }); + describe('ng:style', function(){ + it('should set', function(){ + var scope = compile('
                              '); + scope.$eval(); + expect(element.css('color')).toEqual('red'); + }); - it('should silently ignore undefined ng:style', function() { - var scope = compile('
                              '); - scope.$eval(); - dump(sortedHtml(element)); - expect(element.hasClass('ng-exception')).toBeFalsy(); + it('should silently ignore undefined style', function() { + var scope = compile('
                              '); + scope.$eval(); + expect(element.hasClass('ng-exception')).toBeFalsy(); + }); + + it('should preserve and remove previus style', function(){ + var scope = compile('
                              '); + scope.$eval(); + expect(element.css()).toEqual({color:'red'}); + scope.myStyle = {color:'blue', width:'10px'}; + scope.$eval(); + expect(element.css()).toEqual({color:'blue', width:'10px'}); + scope.myStyle = {}; + scope.$eval(); + expect(element.css()).toEqual({color:'red'}); + }); }); it('should ng:show', function(){ -- cgit v1.2.3 From 17d2ced9cc7e45d1d7272a1217861e598e5522dd Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 14 Jul 2010 17:48:09 -0700 Subject: appease IE on CSS styles --- test/BinderTest.js | 2 +- test/directivesSpec.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/BinderTest.js b/test/BinderTest.js index 1b1201fa..44f918e4 100644 --- a/test/BinderTest.js +++ b/test/BinderTest.js @@ -27,7 +27,7 @@ BinderTest.prototype.testChangingTextfieldUpdatesModel = function(){ state.scope.$eval(); assertEquals('abc', state.scope.model.price); }; - + BinderTest.prototype.testChangingTextareaUpdatesModel = function(){ var c = this.compile(''); c.scope.$eval(); diff --git a/test/directivesSpec.js b/test/directivesSpec.js index 8ce949aa..a42faa9a 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -184,13 +184,13 @@ describe("directives", function(){ it('should preserve and remove previus style', function(){ var scope = compile('
                              '); scope.$eval(); - expect(element.css()).toEqual({color:'red'}); + expect(getStyle(element)).toEqual({color:'red'}); scope.myStyle = {color:'blue', width:'10px'}; scope.$eval(); - expect(element.css()).toEqual({color:'blue', width:'10px'}); + expect(getStyle(element)).toEqual({color:'blue', width:'10px'}); scope.myStyle = {}; scope.$eval(); - expect(element.css()).toEqual({color:'red'}); + expect(getStyle(element)).toEqual({color:'red'}); }); }); -- cgit v1.2.3 From 9abd10e7b8a34b9dcd1a6af5ff37f57bd27cf920 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 15 Jul 2010 13:13:21 -0700 Subject: proper handlig of $element in filters --- test/directivesSpec.js | 72 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 25 deletions(-) (limited to 'test') diff --git a/test/directivesSpec.js b/test/directivesSpec.js index a42faa9a..b6ccf764 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -29,35 +29,57 @@ describe("directives", function(){ expect(scope.a).toEqual(2); }); - it('should ng:bind', function() { - var scope = compile('
                              '); - expect(element.text()).toEqual(''); - scope.a = 'misko'; - scope.$eval(); - expect(element.text()).toEqual('misko'); - }); + describe('ng:bind', function(){ + it('should set text', function() { + var scope = compile('
                              '); + expect(element.text()).toEqual(''); + scope.a = 'misko'; + scope.$eval(); + expect(element.text()).toEqual('misko'); + }); - it('should ng:bind html', function() { - var scope = compile('
                              '); - scope.html = '
                              hello
                              '; - scope.$eval(); - expect(lowercase(element.html())).toEqual('
                              hello
                              '); - }); + it('should set html', function() { + var scope = compile('
                              '); + scope.html = '
                              hello
                              '; + scope.$eval(); + expect(lowercase(element.html())).toEqual('
                              hello
                              '); + }); + + it('should set element element', function() { + angularFilter.myElement = function() { + return jqLite('hello'); + }; + var scope = compile('
                              '); + scope.$eval(); + expect(lowercase(element.html())).toEqual('hello'); + }); + + it('should have $element set to current bind element', function(){ + angularFilter.myFilter = function(){ + this.$element.text('HELLO'); + }; + var scope = compile('
                              before
                              after
                              '); + expect(scope.$element.text()).toEqual("beforeHELLOafter"); + }); - it('should ng:bind element', function() { - angularFilter.myElement = function() { - return jqLite('hello'); - }; - var scope = compile('
                              '); - scope.$eval(); - expect(lowercase(element.html())).toEqual('hello'); }); - it('should ng:bind-template', function() { - var scope = compile('
                              '); - scope.$set('name', 'Misko'); - scope.$eval(); - expect(element.text()).toEqual('Hello Misko!'); + describe('ng:bind-template', function(){ + it('should ng:bind-template', function() { + var scope = compile('
                              '); + scope.$set('name', 'Misko'); + scope.$eval(); + expect(element.text()).toEqual('Hello Misko!'); + }); + + it('should have $element set to current bind element', function(){ + angularFilter.myFilter = function(){ + this.$element.text('HELLO'); + }; + var scope = compile('
                              before
                              after
                              '); + expect(scope.$element.text()).toEqual("beforeHELLOafter"); + }); + }); it('should ng:bind-attr', function(){ -- cgit v1.2.3 From 1de82283dbf1bed2fc04700584dc1123b1e159fe Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 15 Jul 2010 13:35:00 -0700 Subject: proper handlig of $element in filters --- test/directivesSpec.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/directivesSpec.js b/test/directivesSpec.js index b6ccf764..fb1e868a 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -73,11 +73,14 @@ describe("directives", function(){ }); it('should have $element set to current bind element', function(){ - angularFilter.myFilter = function(){ - this.$element.text('HELLO'); + var innerText; + angularFilter.myFilter = function(text){ + innerText = this.$element.text(); + return text; }; - var scope = compile('
                              before
                              after
                              '); + var scope = compile('
                              before
                              INNER
                              after
                              '); expect(scope.$element.text()).toEqual("beforeHELLOafter"); + expect(innerText).toEqual('INNER'); }); }); -- cgit v1.2.3 From 7cef4358aea6f3cfa18dcfb8145d7bc0560bf157 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 15 Jul 2010 14:16:04 -0700 Subject: fixed build --- test/AngularSpec.js | 4 ++++ test/directivesSpec.js | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/AngularSpec.js b/test/AngularSpec.js index de724f03..6d462b14 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -1,3 +1,7 @@ +beforeEach(function(){ + compileCache = {}; +}); + describe('Angular', function(){ xit('should fire on updateEvents', function(){ var onUpdateView = jasmine.createSpy(); diff --git a/test/directivesSpec.js b/test/directivesSpec.js index fb1e868a..dffc8906 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -73,12 +73,12 @@ describe("directives", function(){ }); it('should have $element set to current bind element', function(){ - var innerText; + var innerText = 'blank'; angularFilter.myFilter = function(text){ innerText = this.$element.text(); return text; }; - var scope = compile('
                              before
                              INNER
                              after
                              '); + var scope = compile('
                              beforeINNERafter
                              '); expect(scope.$element.text()).toEqual("beforeHELLOafter"); expect(innerText).toEqual('INNER'); }); @@ -206,7 +206,7 @@ describe("directives", function(){ expect(element.hasClass('ng-exception')).toBeFalsy(); }); - it('should preserve and remove previus style', function(){ + it('should preserve and remove previous style', function(){ var scope = compile('
                              '); scope.$eval(); expect(getStyle(element)).toEqual({color:'red'}); -- cgit v1.2.3 From 7e96af0fdd9af8c479992363f68578305df0337e Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 19 Jul 2010 12:29:24 -0700 Subject: added equals method to angular.equals and $equals --- test/AngularSpec.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test') diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 6d462b14..b4e90175 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -54,3 +54,30 @@ describe("copy", function(){ }); }); + +describe('equals', function(){ + it('should return true if same object', function(){ + var o = {}; + expect(equals(o, o)).toEqual(true); + expect(equals(1, '1')).toEqual(true); + expect(equals(1, '2')).toEqual(false); + }); + + it('should recurse into object', function(){ + expect(equals({}, {})).toEqual(true); + expect(equals({name:'misko'}, {name:'misko'})).toEqual(true); + expect(equals({name:'misko', age:1}, {name:'misko'})).toEqual(false); + expect(equals({name:'misko'}, {name:'misko', age:1})).toEqual(false); + expect(equals({name:'misko'}, {name:'adam'})).toEqual(false); + expect(equals(['misko'], ['misko'])).toEqual(true); + expect(equals(['misko'], ['adam'])).toEqual(false); + expect(equals(['misko'], ['misko', 'adam'])).toEqual(false); + }); + + it('should ignore $ member variables', function(){ + expect(equals({name:'misko', $id:1}, {name:'misko', $id:2})).toEqual(true); + expect(equals({name:'misko'}, {name:'misko', $id:2})).toEqual(true); + expect(equals({name:'misko', $id:1}, {name:'misko'})).toEqual(true); + }); + +}); -- cgit v1.2.3 From bebfbeac0a3f25b3d0df00ada5c919adef9dd701 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 20 Jul 2010 16:55:32 -0700 Subject: fixed xhtml compatibility, fix console in chrome --- test/CompilerSpec.js | 2 +- test/widgetsSpec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/CompilerSpec.js b/test/CompilerSpec.js index da354ea5..3736ff4e 100644 --- a/test/CompilerSpec.js +++ b/test/CompilerSpec.js @@ -22,7 +22,7 @@ describe('compiler', function(){ }; textMarkup = []; attrMarkup = []; - widgets = {}; + widgets = extensionMap({}, 'widget'); compiler = new Compiler(textMarkup, attrMarkup, directives, widgets); compile = function(html){ var e = jqLite("
                              " + html + "
                              "); diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index 03f31bfe..ad98e482 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -407,7 +407,7 @@ describe("widget", function(){ it("should match sandwich ids", function(){ var scope = {}; - var match = angular.widget['NG:SWITCH'].route.call(scope, '/a/123/b', '/a/:id'); + var match = angular.widget('NG:SWITCH').route.call(scope, '/a/123/b', '/a/:id'); expect(match).toBeFalsy(); }); -- cgit v1.2.3 From 0f4b068bd66cde63b222b114dbc1c5fec257a890 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 20 Jul 2010 17:03:34 -0700 Subject: fix test --- test/servicesSpec.js | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'test') diff --git a/test/servicesSpec.js b/test/servicesSpec.js index 32e7812a..90f3d12b 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -33,32 +33,36 @@ describe("service", function(){ describe("$log", function(){ it('should use console if present', function(){ - function log(){}; - function warn(){}; - function info(){}; - function error(){}; + var logger = ""; + function log(){ logger+= 'log;'; }; + function warn(){ logger+= 'warn;'; }; + function info(){ logger+= 'info;'; }; + function error(){ logger+= 'error;'; }; var scope = createScope(null, angularService, {$window: {console:{log:log, warn:warn, info:info, error:error}}}); - expect(scope.$log.log).toEqual(log); - expect(scope.$log.warn).toEqual(warn); - expect(scope.$log.info).toEqual(info); - expect(scope.$log.error).toEqual(error); + scope.$log.log(); + scope.$log.warn(); + scope.$log.info(); + scope.$log.error(); + expect(logger).toEqual('log;warn;info;error;'); }); it('should use console.log if other not present', function(){ - function log(){}; + var logger = ""; + function log(){ logger+= 'log;'; }; var scope = createScope(null, angularService, {$window: {console:{log:log}}}); - expect(scope.$log.log).toEqual(log); - expect(scope.$log.warn).toEqual(log); - expect(scope.$log.info).toEqual(log); - expect(scope.$log.error).toEqual(log); + scope.$log.log(); + scope.$log.warn(); + scope.$log.info(); + scope.$log.error(); + expect(logger).toEqual('log;log;log;log;'); }); it('should use noop if no console', function(){ var scope = createScope(null, angularService, {$window: {}}); - expect(scope.$log.log).toEqual(noop); - expect(scope.$log.warn).toEqual(noop); - expect(scope.$log.info).toEqual(noop); - expect(scope.$log.error).toEqual(noop); + scope.$log.log(); + scope.$log.warn(); + scope.$log.info(); + scope.$log.error(); }); }); -- cgit v1.2.3 From 849a05b5a578f19ddc3d24dc9fbd304e0e07612a Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 22 Jul 2010 11:18:32 -0700 Subject: added jsonp to resources --- test/BrowserSpecs.js | 28 ++++++++++++++++++++++++++-- test/ResourceSpec.js | 12 ++++++++++++ test/angular-mocks.js | 1 + 3 files changed, 39 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/BrowserSpecs.js b/test/BrowserSpecs.js index 3ce158b4..a9f61a6b 100644 --- a/test/BrowserSpecs.js +++ b/test/BrowserSpecs.js @@ -1,10 +1,15 @@ describe('browser', function(){ - var browser, location; + var browser, location, head; beforeEach(function(){ location = {href:"http://server", hash:""}; - browser = new Browser(location, {}); + document = jqLite(window.document); + head = { + scripts: [], + append: function(node){head.scripts.push(node);} + }; + browser = new Browser(location, jqLite(window.document), head); browser.setTimeout = noop; }); @@ -45,4 +50,23 @@ describe('browser', function(){ }); }); + describe('xhr', function(){ + describe('JSON', function(){ + it('should add script tag for request', function() { + var log = ""; + browser.xhr('JSON', 'http://example.org/path?cb=JSON_CALLBACK', function(code, data){ + log += code + ':' + data + ';'; + }); + expect(head.scripts.length).toEqual(1); + var url = head.scripts[0].src.split('?cb='); + expect(url[0]).toEqual('http://example.org/path'); + expect(typeof window[url[1]]).toEqual('function'); + window[url[1]]('data'); + expect(log).toEqual('200:data;'); + expect(typeof window[url[1]]).toEqual('undefined'); + + }); + }); + }); + }); diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js index 4882e70e..6e32ce18 100644 --- a/test/ResourceSpec.js +++ b/test/ResourceSpec.js @@ -28,6 +28,18 @@ describe("resource", function() { resource.route('URL').query(); }); + it('should ignore slashes of undefinend parameters', function(){ + var R = resource.route('/Path/:a/:b/:c'); + xhr.expectGET('/Path').respond({}); + xhr.expectGET('/Path/1').respond({}); + xhr.expectGET('/Path/2/3').respond({}); + xhr.expectGET('/Path/4/5/6').respond({}); + R.get({}); + R.get({a:1}); + R.get({a:2, b:3}); + R.get({a:4, b:5, c:6}); + }); + it("should build resource with default param", function(){ xhr.expectGET('/Order/123/Line/456.visa?minimum=0.05').respond({id:'abc'}); var LineItem = resource.route('/Order/:orderId/Line/:id:verb', {orderId: '123', id: '@id.key', verb:'.visa', minimum:0.05}); diff --git a/test/angular-mocks.js b/test/angular-mocks.js index 8838b2cd..bac2e800 100644 --- a/test/angular-mocks.js +++ b/test/angular-mocks.js @@ -66,6 +66,7 @@ function MockBrowser() { self.xhr.expectPOST = angular.bind(self, self.xhr.expect, 'POST'); self.xhr.expectDELETE = angular.bind(self, self.xhr.expect, 'DELETE'); self.xhr.expectPUT = angular.bind(self, self.xhr.expect, 'PUT'); + self.xhr.expectJSON = angular.bind(self, self.xhr.expect, 'JSON'); self.xhr.flush = function() { while(requests.length) { requests.pop()(); -- cgit v1.2.3 From 2987f7f705baffad8081fc4a3a95eab79b0d9695 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 22 Jul 2010 15:32:57 -0700 Subject: fix howers which were accidently broken --- test/BinderTest.js | 9 +-------- test/directivesSpec.js | 5 ----- 2 files changed, 1 insertion(+), 13 deletions(-) (limited to 'test') diff --git a/test/BinderTest.js b/test/BinderTest.js index 44f918e4..b90d1789 100644 --- a/test/BinderTest.js +++ b/test/BinderTest.js @@ -27,7 +27,7 @@ BinderTest.prototype.testChangingTextfieldUpdatesModel = function(){ state.scope.$eval(); assertEquals('abc', state.scope.model.price); }; - + BinderTest.prototype.testChangingTextareaUpdatesModel = function(){ var c = this.compile(''); c.scope.$eval(); @@ -472,13 +472,6 @@ BinderTest.prototype.testRepeaterShouldBindInputsDefaults = function () { assertEquals("misko", c.scope.$eval('items[1].name')); }; -BinderTest.prototype.testRepeaterShouldCreateArray = function () { - var c = this.compile(''); - c.scope.$eval(); - - assertEquals(0, c.scope.$get('items').length); -}; - BinderTest.prototype.testShouldTemplateBindPreElements = function () { var c = this.compile('
                              Hello {{name}}!
                              '); c.scope.$set("name", "World"); diff --git a/test/directivesSpec.js b/test/directivesSpec.js index dffc8906..8a7da41d 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -140,11 +140,6 @@ describe("directives", function(){ expect(element.text()).toEqual('misko:swe;shyam:set;'); }); - it('should set ng:repeat to [] if undefinde', function(){ - var scope = compile('
                              '); - expect(scope.items).toEqual([]); - }); - it('should error on wrong parsing of ng:repeat', function(){ var scope = compile('
                              '); var log = ""; -- cgit v1.2.3 From 8015e09e383bcd3ebf85d44cd68c67dd85db5771 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 23 Jul 2010 10:48:18 -0700 Subject: added buzz demo, fix undefined() -> undefined --- test/ScopeSpec.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test') diff --git a/test/ScopeSpec.js b/test/ScopeSpec.js index d93400e5..013b1bfc 100644 --- a/test/ScopeSpec.js +++ b/test/ScopeSpec.js @@ -15,6 +15,11 @@ describe('scope/model', function(){ expect(model.$root).toEqual(model); }); + it('should return noop function when LHS is undefined', function(){ + var model = createScope(); + expect(model.$eval('x.$filter()')).toEqual(undefined); + }); + describe('$eval', function(){ it('should eval function with correct this and pass arguments', function(){ var model = createScope(); -- cgit v1.2.3 From 748e91ba92af4a85de3579be504914092381c7e1 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 23 Jul 2010 11:38:52 -0700 Subject: fixed some of the IE bugs --- test/BrowserSpecs.js | 1 - test/servicesSpec.js | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/BrowserSpecs.js b/test/BrowserSpecs.js index a9f61a6b..48387b4d 100644 --- a/test/BrowserSpecs.js +++ b/test/BrowserSpecs.js @@ -4,7 +4,6 @@ describe('browser', function(){ beforeEach(function(){ location = {href:"http://server", hash:""}; - document = jqLite(window.document); head = { scripts: [], append: function(node){head.scripts.push(node);} diff --git a/test/servicesSpec.js b/test/servicesSpec.js index 90f3d12b..031c48f0 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -1,5 +1,5 @@ describe("service", function(){ - var scope, $xhrError, $log; + var scope, $xhrError, $log, mockServices; beforeEach(function(){ $xhrError = jasmine.createSpy('$xhr.error'); @@ -38,7 +38,7 @@ describe("service", function(){ function warn(){ logger+= 'warn;'; }; function info(){ logger+= 'info;'; }; function error(){ logger+= 'error;'; }; - var scope = createScope(null, angularService, {$window: {console:{log:log, warn:warn, info:info, error:error}}}); + var scope = createScope(null, angularService, {$window: {console:{log:log, warn:warn, info:info, error:error}}, $document:[{}]}); scope.$log.log(); scope.$log.warn(); scope.$log.info(); @@ -49,7 +49,7 @@ describe("service", function(){ it('should use console.log if other not present', function(){ var logger = ""; function log(){ logger+= 'log;'; }; - var scope = createScope(null, angularService, {$window: {console:{log:log}}}); + var scope = createScope(null, angularService, {$window: {console:{log:log}}, $document:[{}]}); scope.$log.log(); scope.$log.warn(); scope.$log.info(); @@ -58,7 +58,7 @@ describe("service", function(){ }); it('should use noop if no console', function(){ - var scope = createScope(null, angularService, {$window: {}}); + var scope = createScope(null, angularService, {$window: {}, $document:[{}]}); scope.$log.log(); scope.$log.warn(); scope.$log.info(); -- cgit v1.2.3 From 1a730a9996f6a1ec420e23e5dae0b863b9c7ba12 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 23 Jul 2010 11:46:04 -0700 Subject: fixed some of the IE bugs --- test/BrowserSpecs.js | 1 - 1 file changed, 1 deletion(-) (limited to 'test') diff --git a/test/BrowserSpecs.js b/test/BrowserSpecs.js index 48387b4d..99632928 100644 --- a/test/BrowserSpecs.js +++ b/test/BrowserSpecs.js @@ -63,7 +63,6 @@ describe('browser', function(){ window[url[1]]('data'); expect(log).toEqual('200:data;'); expect(typeof window[url[1]]).toEqual('undefined'); - }); }); }); -- cgit v1.2.3 From b2b170099f957e6575e309c35fed42915e95dd47 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 23 Jul 2010 13:54:12 -0700 Subject: fix issues with ie 7 --- test/BinderTest.js | 4 ++++ test/testabilityPatch.js | 3 +++ 2 files changed, 7 insertions(+) (limited to 'test') diff --git a/test/BinderTest.js b/test/BinderTest.js index b90d1789..f38383ae 100644 --- a/test/BinderTest.js +++ b/test/BinderTest.js @@ -407,6 +407,10 @@ BinderTest.prototype.testBindClass = function() { BinderTest.prototype.testBindClassEvenOdd = function() { var x = this.compile('
                              '); x.scope.$eval(); + var d1 = jqLite(x.node[0].childNodes[1]); + var d2 = jqLite(x.node[0].childNodes[2]); + expect(d1.hasClass('o')).toBeTruthy(); + expect(d2.hasClass('e')).toBeTruthy(); assertEquals( '
                              <#comment>' + '
                              ' + diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index b71943f6..5d0df780 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -63,6 +63,8 @@ function sortedHtml(element) { html += '<' + node.nodeName.toLowerCase(); var attributes = node.attributes || []; var attrs = []; + if (node.className) + attrs.push(' class="' + node.className + '"'); for(var i=0; i"); - form.data('scope', scope); - var c = form.find('c'); - assertTrue(scope === c.scope()); -}; - -ScopeTest.prototype.testGetScopeRetrievalIntermediateNode = function(){ - var scope = {}; - var form = jQuery(""); - form.find("b").data('scope', scope); - var b = form.find('b'); - assertTrue(scope === b.scope()); -}; - -ScopeTest.prototype.testNoScopeDoesNotCauseInfiniteRecursion = function(){ - var form = jQuery(""); - var c = form.find('c'); - assertTrue(!c.scope()); -}; - -ScopeTest.prototype.testScopeEval = function(){ - var scope = new Scope({b:345}); - assertEquals(scope.eval('b = 123'), 123); - assertEquals(scope.get('b'), 123); -}; - -ScopeTest.prototype.testScopeFromPrototype = function(){ - var scope = new Scope({b:123}); - scope.eval('a = b'); - scope.eval('b = 456'); - assertEquals(scope.get('a'), 123); - assertEquals(scope.get('b'), 456); -}; - -ScopeTest.prototype.testSetScopeGet = function(){ - var scope = new Scope(); - assertEquals(987, scope.set('a', 987)); - assertEquals(scope.get('a'), 987); - assertEquals(scope.eval('a'), 987); -}; - -ScopeTest.prototype.testGetChain = function(){ - 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 Scope(); - assertEquals(typeof scope.get('a.b'), 'undefined'); -}; - -ScopeTest.prototype.testSetChain = function(){ - 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 Scope(); - scope.set('a.b', 987); - assertEquals(scope.get('a.b'), 987); - assertEquals(scope.eval('a.b'), 987); -}; - -ScopeTest.prototype.testGlobalFunctionAccess =function(){ - window['scopeAddTest'] = function (a, b) {return a+b;}; - var scope = new Scope({window:window}); - assertEquals(scope.eval('window.scopeAddTest(1,2)'), 3); - - scope.set('add', function (a, b) {return a+b;}); - assertEquals(scope.eval('add(1,2)'), 3); - - scope.set('math.add', function (a, b) {return a+b;}); - assertEquals(scope.eval('math.add(1,2)'), 3); -}; - -ScopeTest.prototype.testValidationEval = function(){ - expectAsserts(4); - var scope = new Scope(); - scope.set("name", "misko"); - angular.validator.testValidator = function(value, expect){ - assertEquals("misko", this.name); - return value == expect ? null : "Error text"; - }; - - assertEquals("Error text", scope.validate("testValidator:'abc'", 'x')); - assertEquals(null, scope.validate("testValidator:'abc'", 'abc')); - - delete angular.validator['testValidator']; -}; - -ScopeTest.prototype.testCallingNonExistantMethodShouldProduceFriendlyException = function() { - expectAsserts(1); - var scope = new Scope({obj:{}}); - try { - scope.eval("obj.iDontExist()"); - fail(); - } catch (e) { - assertEquals("Expression 'obj.iDontExist' is not a function.", e); - } -}; - -ScopeTest.prototype.testAccessingWithInvalidPathShouldThrowError = function() { - var scope = new Scope(); - try { - scope.get('a.{{b}}'); - fail(); - } catch (e) { - assertEquals("Expression 'a.{{b}}' is not a valid expression for accesing variables.", e); - } -}; - -ScopeTest.prototype.testItShouldHave$parent = function() { - 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 Scope({}, "ROOT"); - assertSame(scope.state.$root, scope.state); -}; - -ScopeTest.prototype.testItShouldBuildPathOnUndefined = function(){ - 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 Scope({}, "ROOT"); - scope.set("a", [1,2,3]); - assertEquals('function', typeof scope.get("a.$size")); - scope.eval("a.$includeIf(4,true)"); - assertEquals(4, scope.get("a.$size")()); - assertEquals(4, scope.eval("a.$size()")); - assertEquals('undefined', typeof scope.get("a.dontExist")); -}; diff --git a/test/delete/WidgetsTest.js b/test/delete/WidgetsTest.js deleted file mode 100644 index ccc87afd..00000000 --- a/test/delete/WidgetsTest.js +++ /dev/null @@ -1,268 +0,0 @@ -WidgetTest = TestCase('WidgetTest'); - -WidgetTest.prototype.testRequired = function () { - var view = $(''); - var scope = new Scope({$invalidWidgets:[]}); - var cntl = new TextController(view[0], 'a', angularFormatter.noop); - cntl.updateView(scope); - assertTrue(view.hasClass('ng-validation-error')); - assertEquals("Required Value", view.attr('ng-error')); - scope.set('a', 'A'); - cntl.updateView(scope); - assertFalse(view.hasClass('ng-validation-error')); - assertEquals("undefined", typeof view.attr('ng-error')); -}; - -WidgetTest.prototype.testValidator = function () { - var view = $(''); - var scope = new Scope({$invalidWidgets:[]}); - var cntl = new TextController(view[0], 'a', angularFormatter.noop); - angular.validator.testValidator = function(value, expect){ - return value == expect ? false : "Error text"; - }; - - scope.set('a', ''); - cntl.updateView(scope); - assertEquals(view.hasClass('ng-validation-error'), false); - assertEquals(null, view.attr('ng-error')); - - scope.set('a', 'X'); - cntl.updateView(scope); - assertEquals(view.hasClass('ng-validation-error'), true); - assertEquals(view.attr('ng-error'), "Error text"); - assertEquals("Error text", view.attr('ng-error')); - - scope.set('a', 'ABC'); - cntl.updateView(scope); - assertEquals(view.hasClass('ng-validation-error'), false); - assertEquals(view.attr('ng-error'), null); - assertEquals(null, view.attr('ng-error')); - - delete angular.validator['testValidator']; -}; - -WidgetTest.prototype.testRequiredValidator = function () { - var view = $(''); - var scope = new Scope({$invalidWidgets:[]}); - var cntl = new TextController(view[0], 'a', angularFormatter.noop); - angular.validator.testValidator = function(value, expect){ - return value == expect ? null : "Error text"; - }; - - scope.set('a', ''); - cntl.updateView(scope); - assertEquals(view.hasClass('ng-validation-error'), true); - assertEquals("Required Value", view.attr('ng-error')); - - scope.set('a', 'X'); - cntl.updateView(scope); - assertEquals(view.hasClass('ng-validation-error'), true); - assertEquals("Error text", view.attr('ng-error')); - - scope.set('a', 'ABC'); - cntl.updateView(scope); - assertEquals(view.hasClass('ng-validation-error'), false); - assertEquals(null, view.attr('ng-error')); - - delete angular.validator['testValidator']; -}; - -TextControllerTest = TestCase("TextControllerTest"); - -TextControllerTest.prototype.testDatePicker = function() { - var input = $(''); - input.data('scope', new Scope()); - var body = $(document.body); - body.append(input); - 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')); -}; - -RepeaterUpdaterTest = TestCase("RepeaterUpdaterTest"); - -RepeaterUpdaterTest.prototype.testRemoveThenAdd = function() { - var view = $("
                              "); - var template = function () { - return $("
                            • "); - }; - var repeater = new RepeaterUpdater(view.find("span"), "a in b", template, ""); - var scope = new Scope(); - scope.set('b', [1,2]); - - repeater.updateView(scope); - - scope.set('b', []); - repeater.updateView(scope); - - scope.set('b', [1]); - repeater.updateView(scope); - assertEquals(1, view.find("li").size()); -}; - -RepeaterUpdaterTest.prototype.testShouldBindWidgetOnRepeaterClone = function(){ - //fail(); -}; - -RepeaterUpdaterTest.prototype.testShouldThrowInformativeSyntaxError= function(){ - expectAsserts(1); - try { - var repeater = new RepeaterUpdater(null, "a=b"); - } catch (e) { - assertEquals("Expected ng:repeat in form of 'item in collection' but got 'a=b'.", e); - } -}; - -SelectControllerTest = TestCase("SelectControllerTest"); - -SelectControllerTest.prototype.testShouldUpdateModelNullOnNothingSelected = function(){ - var scope = new Scope(); - var view = {selectedIndex:-1, options:[]}; - var cntl = new SelectController(view, 'abc'); - cntl.updateModel(scope); - assertNull(scope.get('abc')); -}; - -SelectControllerTest.prototype.testShouldUpdateModelWhenNothingSelected = function(){ - var scope = new Scope(); - var view = {value:'123'}; - var cntl = new SelectController(view, 'abc'); - cntl.updateView(scope); - assertEquals("123", scope.get('abc')); -}; - -BindUpdaterTest = TestCase("BindUpdaterTest"); - -BindUpdaterTest.prototype.testShouldDisplayNothingForUndefined = function () { - var view = $(''); - var controller = new BindUpdater(view[0], "{{a}}"); - var scope = new Scope(); - - scope.set('a', undefined); - controller.updateView(scope); - assertEquals("", view.text()); - - scope.set('a', null); - controller.updateView(scope); - assertEquals("", view.text()); -}; - -BindUpdaterTest.prototype.testShouldDisplayJsonForNonStrings = function () { - var view = $(''); - var controller = new BindUpdater(view[0], "{{obj}}"); - - controller.updateView(new Scope({obj:[]})); - assertEquals("[]", view.text()); - - controller.updateView(new Scope({obj:{text:'abc'}})); - assertEquals('abc', fromJson(view.text()).text); -}; - - -BindUpdaterTest.prototype.testShouldInsertHtmlNode = function () { - var view = $(''); - var controller = new BindUpdater(view[0], "&{{obj}}"); - var scope = new Scope(); - - scope.set("obj", $('
                              myDiv
                              ')[0]); - controller.updateView(scope); - assertEquals("&myDiv", view.text()); -}; - - -BindUpdaterTest.prototype.testShouldDisplayTextMethod = function () { - var view = $('
                              '); - 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); - assertEquals("abc", view.text()); - - scope.set("obj", new angular.filter.Meta({text:"123"})); - controller.updateView(scope); - assertEquals("123", view.text()); - - scope.set("obj", {text:"123"}); - controller.updateView(scope); - assertEquals("123", fromJson(view.text()).text); -}; - -BindUpdaterTest.prototype.testShouldDisplayHtmlMethod = function () { - var view = $('
                              '); - var controller = new BindUpdater(view[0], "{{obj}}"); - var scope = new Scope(); - - scope.set("obj", new angular.filter.Meta({html:function(){return "a
                              b
                              c";}})); - controller.updateView(scope); - assertEquals("abc", view.text()); - - scope.set("obj", new angular.filter.Meta({html:"1
                              2
                              3"})); - controller.updateView(scope); - assertEquals("123", view.text()); - - scope.set("obj", {html:"123"}); - controller.updateView(scope); - assertEquals("123", fromJson(view.text()).html); -}; - -BindUpdaterTest.prototype.testUdateBoolean = function() { - var view = $('
                              '); - var controller = new BindUpdater(view[0], "{{true}}, {{false}}"); - controller.updateView(new Scope()); - assertEquals('true, false', view.text()); -}; - -BindAttrUpdaterTest = TestCase("BindAttrUpdaterTest"); - -BindAttrUpdaterTest.prototype.testShouldLoadBlankImageWhenBindingIsUndefined = function () { - var view = $(''); - var controller = new BindAttrUpdater(view[0], {src: '{{imageUrl}}'}); - - var scope = new Scope(); - scope.set('imageUrl', undefined); - scope.set('$config.blankImage', 'http://server/blank.gif'); - - controller.updateView(scope); - assertEquals("http://server/blank.gif", view.attr('src')); -}; - -RepeaterUpdaterTest.prototype.testShouldNotDieWhenRepeatExpressionIsNull = function() { - 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 RepeaterUpdater(null, "($k,_v) in items", null, null); - assertEquals("items", rep.iteratorExp); - assertEquals("_v", rep.valueExp); - assertEquals("$k", rep.keyExp); -}; - -EvalUpdaterTest = TestCase("EvalUpdaterTest"); -EvalUpdaterTest.prototype.testEvalThrowsException = function(){ - var view = $('
                              '); - var eval = new EvalUpdater(view[0], 'undefined()'); - - eval.updateView(new Scope()); - assertTrue(!!view.attr('ng-error')); - assertTrue(view.hasClass('ng-exception')); - - eval.exp = "1"; - eval.updateView(new Scope()); - assertFalse(!!view.attr('ng-error')); - assertFalse(view.hasClass('ng-exception')); -}; - -RadioControllerTest = TestCase("RadioController"); -RadioControllerTest.prototype.testItShouldTreatTrueStringAsBoolean = function () { - var view = $(''); - var radio = new RadioController(view[0], 'select'); - var scope = new Scope({select:true}); - radio.updateView(scope); - assertTrue(view[0].checked); -}; diff --git a/test/moveToAngularCom/Base64Test.js b/test/moveToAngularCom/Base64Test.js deleted file mode 100644 index a9353186..00000000 --- a/test/moveToAngularCom/Base64Test.js +++ /dev/null @@ -1,5 +0,0 @@ -Base64Test = TestCase('Base64Test'); - -Base64Test.prototype.testEncodeDecode = function(){ - assertEquals(Base64.decode(Base64.encode('hello')), 'hello'); -}; diff --git a/test/moveToAngularCom/DataStoreTest.js b/test/moveToAngularCom/DataStoreTest.js deleted file mode 100644 index 87c5be2e..00000000 --- a/test/moveToAngularCom/DataStoreTest.js +++ /dev/null @@ -1,616 +0,0 @@ -DataStoreTest = TestCase('DataStoreTest'); - -DataStoreTest.prototype.testSavePostsToServer = function(){ - expectAsserts(10); - var response; - var post = function(data, callback){ - var method = data[0][0]; - var posted = data[0][2]; - assertEquals("POST", method); - assertEquals("abc", posted.$entity); - assertEquals("123", posted.$id); - assertEquals("1", posted.$version); - assertFalse('function' == typeof posted.save); - response = fromJson(toJson(posted)); - response.$entity = "abc"; - response.$id = "123"; - response.$version = "2"; - callback(200, [response]); - }; - var datastore = new DataStore(post); - var model = datastore.entity('abc', {name: "value"})(); - model.$id = "123"; - model.$version = "1"; - - datastore.save(model, function(obj){ - assertTrue(obj === model); - assertEquals(obj.$entity, "abc"); - assertEquals(obj.$id, "123"); - assertEquals(obj.$version, "2"); - assertEquals(obj.name, "value"); - obj.after = true; - }); - datastore.flush(); -}; - -DataStoreTest.prototype.testLoadGetsFromServer = function(){ - expectAsserts(12); - var post = function(data, callback){ - var method = data[0][0]; - var path = data[0][1]; - assertEquals("GET", method); - assertEquals("abc/1", path); - response = [{$entity:'abc', $id:'1', $version:'2', key:"value"}]; - callback(200, response); - }; - var datastore = new DataStore(post); - - var model = datastore.entity("abc", {merge:true})(); - assertEquals(datastore.load(model, '1', function(obj){ - assertEquals(obj.$entity, "abc"); - assertEquals(obj.$id, "1"); - assertEquals(obj.$version, "2"); - assertEquals(obj.key, "value"); - }), model); - datastore.flush(); - assertEquals(model.$entity, "abc"); - assertEquals(model.$id, "1"); - assertEquals(model.$version, "2"); - assertEquals(model.key, "value"); - assertEquals(model.merge, true); -}; - -DataStoreTest.prototype.testRemove = function(){ - expectAsserts(8); - var response; - var post = function(data, callback){ - var method = data[0][0]; - var posted = data[0][2]; - assertEquals("DELETE", method); - assertEquals("abc", posted.$entity); - assertEquals("123", posted.$id); - assertEquals("1", posted.$version); - assertFalse('function' == typeof posted.save); - response = fromJson(toJson(posted)); - response.$entity = "abc"; - response.$id = "123"; - response.$version = "2"; - callback(200, [response]); - }; - var model; - var datastore = new DataStore(post); - model = datastore.entity('abc', {name: "value"})(); - model.$id = "123"; - model.$version = "1"; - - datastore.remove(model, function(obj){ - assertEquals(obj.$id, "123"); - assertEquals(obj.$version, "2"); - assertEquals(obj.name, "value"); - obj.after = true; - }); - datastore.flush(); - -}; - - -DataStoreTest.prototype.test401ResponseDoesNotCallCallback = function(){ - expectAsserts(1); - var post = function(data, callback) { - callback(200, {$status_code: 401}); - }; - - var datastore = new DataStore(post, {login:function(){ - assertTrue(true); - }}); - - var onLoadAll = function(){ - assertTrue(false, "onLoadAll should not be called when response is status 401"); - }; - datastore.bulkRequest.push({}); - datastore.flush(); - datastore.loadAll({type: "A"}, onLoadAll); -}; - -DataStoreTest.prototype.test403ResponseDoesNotCallCallback = function(){ - expectAsserts(1); - var post = function(data, callback) { - callback(200, [{$status_code: 403}]); - }; - - var datastore = new DataStore(post, {notAuthorized:function(){ - assertTrue(true); - }}); - - var onLoadAll = function(){ - assertTrue(false, "onLoadAll should not be called when response is status 403"); - }; - datastore.bulkRequest.push({}); - datastore.flush(); - datastore.loadAll({type: "A"}, onLoadAll); -}; - -DataStoreTest.prototype.testLoadCalledWithoutIdShouldBeNoop = function(){ - expectAsserts(2); - var post = function(url, callback){ - assertTrue(false); - }; - 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 DataStore(); - var Recipe = ds.entity("Recipe", {a:1, b:2}); - assertEquals(Recipe.title, "Recipe"); - assertEquals(Recipe.defaults.a, 1); - assertEquals(Recipe.defaults.b, 2); - - var recipe = Recipe(); - assertEquals(recipe.$entity, "Recipe"); - assertEquals(recipe.a, 1); - assertEquals(recipe.b, 2); - - recipe = new Recipe(); - assertEquals(recipe.$entity, "Recipe"); - assertEquals(recipe.a, 1); - assertEquals(recipe.b, 2); -}; - -DataStoreTest.prototype.testEntityFactoryNoDefaults = function(){ - var ds = new DataStore(); - var Recipe = ds.entity("Recipe"); - assertEquals(Recipe.title, "Recipe"); - - recipe = new Recipe(); - assertEquals(recipe.$entity, "Recipe"); -}; - -DataStoreTest.prototype.testEntityFactoryWithInitialValues = function(){ - var ds = new DataStore(); - var Recipe = ds.entity("Recipe"); - - var recipe = Recipe({name: "name"}); - assertEquals("name", recipe.name); -}; - -DataStoreTest.prototype.testEntityLoad = function(){ - var ds = new DataStore(); - var Recipe = ds.entity("Recipe", {a:1, b:2}); - ds.load = function(instance, id, callback){ - callback.apply(instance); - return instance; - }; - var instance = null; - var recipe2 = Recipe.load("ID", function(){ - instance = this; - }); - assertTrue(recipe2 === instance); -}; - -DataStoreTest.prototype.testSaveScope = function(){ - var ds = new DataStore(); - var log = ""; - var Person = ds.entity("Person"); - var person1 = Person({name:"A", $entity:"Person", $id:"1", $version:"1"}, ds); - person1.$$anchor = "A"; - var person2 = Person({name:"B", $entity:"Person", $id:"2", $version:"2"}, ds); - person2.$$anchor = "B"; - var anchor = {}; - ds.anchor = anchor; - ds._jsonRequest = function(request, callback){ - log += "save(" + request[2].$id + ");"; - callback({$id:request[2].$id}); - }; - ds.saveScope({person1:person1, person2:person2, - ignoreMe:{name: "ignore", save:function(callback){callback();}}}, function(){ - log += "done();"; - }); - assertEquals("save(1);save(2);done();", log); - assertEquals(1, anchor.A); - assertEquals(2, anchor.B); -}; - -DataStoreTest.prototype.testEntityLoadAllRows = function(){ - var ds = new DataStore(); - var Recipe = ds.entity("Recipe"); - var list = []; - ds.loadAll = function(entity, callback){ - assertTrue(Recipe === entity); - callback.apply(list); - return list; - }; - var items = Recipe.all(function(){ - assertTrue(list === this); - }); - assertTrue(items === list); -}; - -DataStoreTest.prototype.testLoadAll = function(){ - expectAsserts(8); - var post = function(data, callback){ - assertEquals("GET", data[0][0]); - assertEquals("A", data[0][1]); - callback(200, [[{$entity:'A', $id:'1'},{$entity:'A', $id:'2'}]]); - }; - var datastore = new DataStore(post); - var list = datastore.entity("A").all(function(){ - assertTrue(true); - }); - datastore.flush(); - assertEquals(list.length, 2); - assertEquals(list[0].$entity, "A"); - assertEquals(list[0].$id, "1"); - assertEquals(list[1].$entity, "A"); - assertEquals(list[1].$id, "2"); -}; - -DataStoreTest.prototype.testQuery = function(){ - expectAsserts(5); - var post = function(data, callback) { - assertEquals("GET", data[0][0]); - assertEquals("Employee/managerId=123abc", data[0][1]); - callback(200, [[{$entity:"Employee", $id: "456", managerId: "123ABC"}]]); - - }; - var datastore = new DataStore(post); - var Employee = datastore.entity("Employee"); - var list = Employee.query('managerId', "123abc", function(){ - assertTrue(true); - }); - datastore.flush(); - assertJsonEquals([[{$entity:"Employee", $id: "456", managerId: "123ABC"}]], datastore._cache.$collections); - assertEquals(list[0].$id, "456"); -}; - -DataStoreTest.prototype.testLoadingDocumentRefreshesExistingArrays = function() { - expectAsserts(12); - var post; - 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"}, - {$id:2, $entity:"Book", name:"Dick"}]]); - }; - var allBooks = Book.all(); - datastore.flush(); - var queryBooks = Book.query("a", "b"); - datastore.flush(); - assertEquals("Moby", allBooks[0].name); - assertEquals("Dick", allBooks[1].name); - assertEquals("Moby", queryBooks[0].name); - assertEquals("Dick", queryBooks[1].name); - - post = function(req, callback) { - assertEquals('[["GET","Book/1"]]', toJson(req)); - callback(200, [{$id:1, $entity:"Book", name:"Moby Dick"}]); - }; - var book = Book.load(1); - datastore.flush(); - assertEquals("Moby Dick", book.name); - assertEquals("Moby Dick", allBooks[0].name); - assertEquals("Moby Dick", queryBooks[0].name); - - post = function(req, callback) { - assertEquals('POST', req[0][0]); - callback(200, [{$id:1, $entity:"Book", name:"The Big Fish"}]); - }; - book.$save(); - datastore.flush(); - assertEquals("The Big Fish", book.name); - assertEquals("The Big Fish", allBooks[0].name); - assertEquals("The Big Fish", queryBooks[0].name); -}; - -DataStoreTest.prototype.testEntityProperties = function() { - expectAsserts(2); - var datastore = new DataStore(); - var callback = {}; - - datastore._jsonRequest = function(request, callbackFn) { - assertJsonEquals(["GET", "Cheese/$properties"], request); - assertEquals(callback, callbackFn); - }; - - var Cheese = datastore.entity("Cheese"); - Cheese.properties(callback); - -}; - -DataStoreTest.prototype.testLoadInstanceIsNotFromCache = function() { - var post; - var datastore = new DataStore(function(r, c){post(r,c);}); - var Book = datastore.entity('Book'); - - post = function(req, callback) { - assertEquals('[["GET","Book/1"]]', toJson(req)); - callback(200, [{$id:1, $entity:"Book", name:"Moby Dick"}]); - }; - var book = Book.load(1); - datastore.flush(); - assertEquals("Moby Dick", book.name); - assertFalse(book === datastore._cache['Book/1']); -}; - -DataStoreTest.prototype.testLoadStarsIsNewDocument = function() { - var datastore = new DataStore(); - var Book = datastore.entity('Book'); - var book = Book.load('*'); - assertEquals('Book', book.$entity); -}; - -DataStoreTest.prototype.testUndefinedEntityReturnsNullValueObject = function() { - var datastore = new DataStore(); - var Entity = datastore.entity(undefined); - var all = Entity.all(); - assertEquals(0, all.length); -}; - -DataStoreTest.prototype.testFetchEntities = function(){ - expectAsserts(6); - var post = function(data, callback){ - assertJsonEquals(["GET", "$entities"], data[0]); - callback(200, [{A:0, B:0}]); - }; - var datastore = new DataStore(post); - var entities = datastore.entities(function(){ - assertTrue(true); - }); - datastore.flush(); - assertJsonEquals([], datastore.bulkRequest); - assertEquals(2, entities.length); - assertEquals("A", entities[0].title); - assertEquals("B", entities[1].title); -}; - -DataStoreTest.prototype.testItShouldMigrateSchema = function() { - 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( - toJson({a:[], b:'abc', user:{name:"Misko", email:"misko@hevery.com"}}) == - toJson(doc)); - doc.$migrate(); - assertEquals( - toJson({a:[], b:'abc', user:{name:"Misko", email:"misko@hevery.com"}}), - toJson(doc)); -}; - -DataStoreTest.prototype.testItShouldCollectRequestsForBulk = function() { - var ds = new DataStore(); - var Book = ds.entity("Book"); - var Library = ds.entity("Library"); - Book.all(); - Library.load("123"); - assertEquals(2, ds.bulkRequest.length); - assertJsonEquals(["GET", "Book"], ds.bulkRequest[0]); - assertJsonEquals(["GET", "Library/123"], ds.bulkRequest[1]); -}; - -DataStoreTest.prototype.testEmptyFlushShouldDoNothing = function () { - var ds = new DataStore(function(){ - fail("expecting noop"); - }); - ds.flush(); -}; - -DataStoreTest.prototype.testFlushShouldCallAllCallbacks = function() { - var log = ""; - function post(request, callback){ - log += 'BulkRequest:' + toJson(request) + ';'; - callback(200, [[{$id:'ABC'}], {$id:'XYZ'}]); - } - var ds = new DataStore(post); - var Book = ds.entity("Book"); - var Library = ds.entity("Library"); - Book.all(function(instance){ - log += toJson(instance) + ';'; - }); - Library.load("123", function(instance){ - log += toJson(instance) + ';'; - }); - assertEquals("", log); - ds.flush(); - assertJsonEquals([], ds.bulkRequest); - assertEquals('BulkRequest:[["GET","Book"],["GET","Library/123"]];[{"$id":"ABC"}];{"$id":"XYZ"};', log); -}; - -DataStoreTest.prototype.testSaveOnNotLoggedInRetriesAfterLoggin = function(){ - var log = ""; - var book; - var ds = new DataStore(null, {login:function(c){c();}}); - ds.post = function (request, callback){ - assertJsonEquals([["POST", "", book]], request); - ds.post = function(request, callback){ - assertJsonEquals([["POST", "", book]], request); - ds.post = function(){fail("too much recursion");}; - callback(200, [{saved:"ok"}]); - }; - callback(200, {$status_code:401}); - }; - book = ds.entity("Book")({name:"misko"}); - book.$save(); - ds.flush(); - assertJsonEquals({saved:"ok"}, book); -}; - -DataStoreTest.prototype.testItShouldRemoveItemFromCollectionWhenDeleted = function() { - expectAsserts(6); - var ds = new DataStore(); - ds.post = function(request, callback){ - assertJsonEquals([["GET", "Book"]], request); - callback(200, [[{name:"Moby Dick", $id:123, $entity:'Book'}]]); - }; - var Book = ds.entity("Book"); - var books = Book.all(); - ds.flush(); - assertJsonEquals([[{name:"Moby Dick", $id:123, $entity:'Book'}]], ds._cache.$collections); - assertDefined(ds._cache['Book/123']); - var book = Book({$id:123}); - ds.post = function(request, callback){ - assertJsonEquals([["DELETE", "", book]], request); - callback(200, [book]); - }; - ds.remove(book); - ds.flush(); - assertUndefined(ds._cache['Book/123']); - assertJsonEquals([[]],ds._cache.$collections); -}; - -DataStoreTest.prototype.testItShouldAddToAll = function() { - expectAsserts(8); - var ds = new DataStore(); - ds.post = function(request, callback){ - assertJsonEquals([["GET", "Book"]], request); - callback(200, [[]]); - }; - var Book = ds.entity("Book"); - var books = Book.all(); - assertEquals(0, books.length); - ds.flush(); - var moby = Book({name:'moby'}); - moby.$save(); - ds.post = function(request, callback){ - assertJsonEquals([["POST", "", moby]], request); - moby.$id = '123'; - callback(200, [moby]); - }; - ds.flush(); - assertEquals(1, books.length); - assertEquals(moby, books[0]); - - moby.$save(); - ds.flush(); - assertEquals(1, books.length); - assertEquals(moby, books[0]); -}; - -DataStoreTest.prototype.testItShouldReturnCreatedDocumentCountByUser = function(){ - expectAsserts(2); - var datastore = new DataStore( - function(request, callback){ - assertJsonEquals([["GET", "$users"]], request); - callback(200, [{misko:1, adam:1}]); - }); - var users = datastore.documentCountsByUser(); - assertJsonEquals({misko:1, adam:1}, users); -}; - - -DataStoreTest.prototype.testItShouldReturnDocumentIdsForUeserByEntity = function(){ - expectAsserts(2); - var datastore = new DataStore( - function(request, callback){ - assertJsonEquals([["GET", "$users/misko@hevery.com"]], request); - callback(200, [{Book:["1"], Library:["2"]}]); - }); - var users = datastore.userDocumentIdsByEntity("misko@hevery.com"); - assertJsonEquals({Book:["1"], Library:["2"]}, users); -}; - -DataStoreTest.prototype.testItShouldReturnNewInstanceOn404 = function(){ - expectAsserts(7); - var log = ""; - var datastore = new DataStore( - function(request, callback){ - assertJsonEquals([["GET", "User/misko"]], request); - callback(200, [{$status_code:404}]); - }); - var User = datastore.entity("User", {admin:false}); - var user = User.loadOrCreate('misko', function(i){log+="cb "+i.$id+";";}); - datastore.flush(); - assertEquals("misko", user.$id); - assertEquals("User", user.$entity); - assertEquals(false, user.admin); - assertEquals("undefined", typeof user.$secret); - assertEquals("undefined", typeof user.$version); - assertEquals("cb misko;", log); -}; - -DataStoreTest.prototype.testItShouldReturnNewInstanceOn404 = function(){ - var log = ""; - 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 "+toJson(i)+";";}); - datastore.flush(); - assertEquals("misko", users[0].$id); - assertEquals("adam", users[1].$id); - assertEquals('cb [{"$id":"misko"},{"$id":"adam"}];', log); -}; - -DataStoreTest.prototype.testItShouldCreateJoinAndQuery = function() { - var datastore = new DataStore(); - var Invoice = datastore.entity("Invoice"); - var Customer = datastore.entity("Customer"); - var InvoiceWithCustomer = datastore.join({ - invoice:{join:Invoice}, - customer:{join:Customer, on:"invoice.customer"} - }); - var invoiceWithCustomer = InvoiceWithCustomer.query("invoice.month", 1); - assertEquals([], invoiceWithCustomer); - assertJsonEquals([["GET", "Invoice/month=1"]], datastore.bulkRequest); - var request = datastore.bulkRequest.shift(); - request.$$callback([{$id:1, customer:1},{$id:2, customer:1},{$id:3, customer:3}]); - assertJsonEquals([["GET","Customer/1"],["GET","Customer/3"]], datastore.bulkRequest); - datastore.bulkRequest.shift().$$callback({$id:1}); - datastore.bulkRequest.shift().$$callback({$id:3}); - assertJsonEquals([ - {invoice:{$id:1,customer:1},customer:{$id:1}}, - {invoice:{$id:2,customer:1},customer:{$id:1}}, - {invoice:{$id:3,customer:3},customer:{$id:3}}], invoiceWithCustomer); -}; - -DataStoreTest.prototype.testItShouldThrowIfMoreThanOneEntityIsPrimary = function() { - var datastore = new DataStore(); - var Invoice = datastore.entity("Invoice"); - var Customer = datastore.entity("Customer"); - assertThrows("Exactly one entity needs to be primary.", function(){ - datastore.join({ - invoice:{join:Invoice}, - customer:{join:Customer} - }); - }); -}; - -DataStoreTest.prototype.testItShouldThrowIfLoopInReferences = function() { - var datastore = new DataStore(); - var Invoice = datastore.entity("Invoice"); - var Customer = datastore.entity("Customer"); - assertThrows("Infinite loop in join: invoice -> customer", function(){ - datastore.join({ - invoice:{join:Invoice, on:"customer.invoice"}, - customer:{join:Customer, on:"invoice.customer"} - }); - }); -}; - -DataStoreTest.prototype.testItShouldThrowIfReferenceToNonExistantJoin = function() { - var datastore = new DataStore(); - var Invoice = datastore.entity("Invoice"); - var Customer = datastore.entity("Customer"); - assertThrows("Named entity 'x' is undefined.", function(){ - datastore.join({ - invoice:{join:Invoice, on:"x.invoice"}, - customer:{join:Customer, on:"invoice.customer"} - }); - }); -}; - -DataStoreTest.prototype.testItShouldThrowIfQueryOnNonPrimary = function() { - var datastore = new DataStore(); - var Invoice = datastore.entity("Invoice"); - var Customer = datastore.entity("Customer"); - var InvoiceWithCustomer = datastore.join({ - invoice:{join:Invoice}, - customer:{join:Customer, on:"invoice.customer"} - }); - assertThrows("Named entity 'customer' is not a primary entity.", function(){ - InvoiceWithCustomer.query("customer.month", 1); - }); -}; diff --git a/test/moveToAngularCom/EntityDeclarationTest.js b/test/moveToAngularCom/EntityDeclarationTest.js deleted file mode 100644 index 28986ea8..00000000 --- a/test/moveToAngularCom/EntityDeclarationTest.js +++ /dev/null @@ -1,50 +0,0 @@ -EntityDeclarationTest = TestCase('EntityDeclarationTest'); - -EntityDeclarationTest.prototype.testEntityTypeOnly = function(){ - expectAsserts(2); - var datastore = {entity:function(name){ - assertEquals("Person", name); - }}; - var scope = new Scope(); - var init = scope.entity("Person", datastore); - assertEquals("", init); -}; - -EntityDeclarationTest.prototype.testWithDefaults = function(){ - expectAsserts(4); - var datastore = {entity:function(name, init){ - assertEquals("Person", name); - assertEquals("=a:", init.a); - assertEquals(0, init.b.length); - }}; - var scope = new Scope(); - var init = scope.entity('Person:{a:"=a:", b:[]}', datastore); - assertEquals("", init); -}; - -EntityDeclarationTest.prototype.testWithName = function(){ - expectAsserts(2); - var datastore = {entity:function(name, init){ - assertEquals("Person", name); - return function (){ return {}; }; - }}; - var scope = new Scope(); - var init = scope.entity('friend=Person', datastore); - assertEquals("$anchor.friend:{friend=Person.load($anchor.friend);friend.$$anchor=\"friend\";};", init); -}; - -EntityDeclarationTest.prototype.testMultipleEntities = function(){ - expectAsserts(3); - var expect = ['Person', 'Book']; - var i=0; - var datastore = {entity:function(name, init){ - assertEquals(expect[i], name); - i++; - return function (){ return {}; }; - }}; - var scope = new Scope(); - var init = scope.entity('friend=Person;book=Book;', datastore); - assertEquals("$anchor.friend:{friend=Person.load($anchor.friend);friend.$$anchor=\"friend\";};" + - "$anchor.book:{book=Book.load($anchor.book);book.$$anchor=\"book\";};", - init); -}; diff --git a/test/moveToAngularCom/FileControllerTest.js b/test/moveToAngularCom/FileControllerTest.js deleted file mode 100644 index 75c924e6..00000000 --- a/test/moveToAngularCom/FileControllerTest.js +++ /dev/null @@ -1,98 +0,0 @@ -FileControllerTest = TestCase('FileControllerTest'); - -FileControllerTest.prototype.XtestOnSelectUpdateView = function(){ - var view = jQuery(''); - var swf = {}; - var controller = new FileController(view, null, swf); - swf.uploadFile = function(path){}; - controller.select('A', 9, '9 bytes'); - assertEquals(view.find('a').text(), "A"); - assertEquals(view.find('span').text(), "9 bytes"); -}; - -FileControllerTest.prototype.XtestUpdateModelView = function(){ - var view = FileController.template(''); - var input = $(''); - var controller; - var scope = new Scope({value:{}, $binder:{updateView:function(){ - controller.updateView(scope); - }}}); - view.data('scope', scope); - controller = new FileController(view, 'value.input', null, "http://server_base"); - var value = '{"text":"A", "size":123, "id":"890"}'; - controller.uploadCompleteData(value); - controller.updateView(scope); - assertEquals(scope.get('value.input.text'), 'A'); - assertEquals(scope.get('value.input.size'), 123); - assertEquals(scope.get('value.input.id'), '890'); - assertEquals(scope.get('value.input.url'), 'http://server_base/_attachments/890/A'); - assertEquals(view.find('a').text(), "A"); - assertEquals(view.find('a').attr('href'), "http://server_base/_attachments/890/A"); - assertEquals(view.find('span').text(), "123 bytes"); -}; - -FileControllerTest.prototype.XtestFileUpload = function(){ - expectAsserts(1); - var swf = {}; - var controller = new FileController(null, null, swf, "http://server_base"); - swf.uploadFile = function(path){ - assertEquals("http://server_base/_attachments", path); - }; - controller.name = "Name"; - controller.upload(); -}; - -FileControllerTest.prototype.XtestFileUploadNoFileIsNoop = function(){ - expectAsserts(0); - var swf = {uploadFile:function(path){ - fail(); - }}; - var controller = new FileController(null, swf); - controller.upload("basePath", null); -}; - -FileControllerTest.prototype.XtestRemoveAttachment = function(){ - var doc = FileController.template(); - var input = $(''); - var scope = new Scope(); - input.data('scope', scope); - var controller = new FileController(doc, 'file', null, null); - controller.updateView(scope); - assertEquals(false, doc.find('input').attr('checked')); - - scope.set('file', {url:'url', size:123}); - controller.updateView(scope); - assertEquals(true, doc.find('input').attr('checked')); - - doc.find('input').attr('checked', false); - controller.updateModel(scope); - assertNull(scope.get('file')); - - doc.find('input').attr('checked', true); - controller.updateModel(scope); - assertEquals('url', scope.get('file.url')); - assertEquals(123, scope.get('file.size')); -}; - -FileControllerTest.prototype.XtestShouldEmptyOutOnUndefined = function () { - var view = FileController.template('hello'); - var controller = new FileController(view, 'abc', null, null); - - var scope = new Scope(); - scope.set('abc', {text: 'myname', url: 'myurl', size: 1234}); - - controller.updateView(scope); - assertEquals("myurl", view.find('a').attr('href')); - assertEquals("myname", view.find('a').text()); - assertEquals(true, view.find('input').is(':checked')); - assertEquals("1.2 KB", view.find('span').text()); - - scope.set('abc', undefined); - controller.updateView(scope); - assertEquals("myurl", view.find('a').attr('href')); - assertEquals("myname", view.find('a').text()); - assertEquals(false, view.find('input').is(':checked')); - assertEquals("1.2 KB", view.find('span').text()); -}; - - diff --git a/test/moveToAngularCom/MiscTest.js b/test/moveToAngularCom/MiscTest.js deleted file mode 100644 index aa0e1186..00000000 --- a/test/moveToAngularCom/MiscTest.js +++ /dev/null @@ -1,35 +0,0 @@ -BinderTest.prototype.testExpandEntityTagWithName = function(){ - var c = this.compile('
                              '); - assertEquals( - '
                              ', - sortedHtml(c.node)); - assertEquals("Person", c.scope.$get("friend.$entity")); - assertEquals("friend", c.scope.$get("friend.$$anchor")); -}; - -BinderTest.prototype.testExpandSubmitButtonToAction = function(){ - var html = this.compileToHtml(''); - assertTrue(html, html.indexOf('ng-action="$save()"') > 0 ); - assertTrue(html, html.indexOf('ng-bind-attr="{"disabled":"{{$invalidWidgets}}"}"') > 0 ); -}; - -BinderTest.prototype.testReplaceFileUploadWithSwf = function(){ - expectAsserts(1); - var form = jQuery("body").append('
                              '); - form.data('scope', new Scope()); - var factory = {}; - var binder = new Binder(form.get(0), factory, new MockLocation()); - factory.createController = function(node){ - assertEquals(node.attr('type'), 'file'); - return {updateModel:function(){}}; - }; - binder.compile(); - jQuery("#testTag").remove(); -}; - -BinderTest.prototype.testExpandEntityTagWithDefaults = function(){ - assertEquals( - '
                              ', - this.compileToHtml('
                              ')); -}; - diff --git a/test/moveToAngularCom/ModelTest.js b/test/moveToAngularCom/ModelTest.js deleted file mode 100644 index dbd97778..00000000 --- a/test/moveToAngularCom/ModelTest.js +++ /dev/null @@ -1,84 +0,0 @@ -ModelTest = TestCase('ModelTest'); - -ModelTest.prototype.testLoadSaveOperations = function(){ - var m1 = new DataStore().entity('A')(); - m1.a = 1; - - var m2 = {b:1}; - - m1.$loadFrom(m2); - - assertTrue(!m1.a); - assertEquals(m1.b, 1); -}; - -ModelTest.prototype.testLoadfromDoesNotClobberFunctions = function(){ - var m1 = new DataStore().entity('A')(); - m1.id = function(){return 'OK';}; - m1.$loadFrom({id:null}); - assertEquals(m1.id(), 'OK'); - - m1.b = 'OK'; - m1.$loadFrom({b:function(){}}); - assertEquals(m1.b, 'OK'); -}; - -ModelTest.prototype.testDataStoreDoesNotGetClobbered = function(){ - var ds = new DataStore(); - var m = ds.entity('A')(); - assertTrue(m.$$entity.datastore === ds); - m.$loadFrom({}); - assertTrue(m.$$entity.datastore === ds); -}; - -ModelTest.prototype.testManagedModelDelegatesMethodsToDataStore = function(){ - expectAsserts(7); - var datastore = new DataStore(); - var model = datastore.entity("A", {a:1})(); - var fn = {}; - datastore.save = function(instance, callback) { - assertTrue(model === instance); - assertTrue(callback === fn); - }; - datastore.remove = function(instance, callback) { - assertTrue(model === instance); - assertTrue(callback === fn); - }; - datastore.load = function(instance, id, callback) { - assertTrue(model === instance); - assertTrue(id === "123"); - assertTrue(callback === fn); - }; - model.$save(fn); - model.$delete(fn); - model.$loadById("123", fn); -}; - -ModelTest.prototype.testManagedModelCanBeForcedToFlush = function(){ - expectAsserts(6); - var datastore = new DataStore(); - var model = datastore.entity("A", {a:1})(); - - datastore.save = function(instance, callback) { - assertTrue(model === instance); - assertTrue(callback === undefined); - }; - datastore.remove = function(instance, callback) { - assertTrue(model === instance); - assertTrue(callback === undefined); - }; - datastore.flush = function(){ - assertTrue(true); - }; - model.$save(true); - model.$delete(true); -}; - - -ModelTest.prototype.testItShouldMakeDeepCopyOfInitialValues = function (){ - var initial = {a:[]}; - var entity = new DataStore().entity("A", initial); - var model = entity(); - model.a.push(1); - assertEquals(0, entity().a.length); -}; diff --git a/test/moveToAngularCom/ServerTest.js b/test/moveToAngularCom/ServerTest.js deleted file mode 100644 index 02fab84c..00000000 --- a/test/moveToAngularCom/ServerTest.js +++ /dev/null @@ -1,42 +0,0 @@ -ServerTest = TestCase("ServerTest"); -ServerTest.prototype.testBreakLargeRequestIntoPackets = function() { - var log = ""; - var server = new Server("http://server", function(url){ - log += "|" + url; - }); - server.maxSize = 30; - server.uuid = "uuid"; - server.request("POST", "/data/database", {}, function(code, r){ - assertEquals(200, code); - assertEquals("response", r); - }); - angularCallbacks.uuid0("response"); - assertEquals( - "|http://server/$/uuid0/2/1?h=eyJtIjoiUE9TVCIsInAiOnt9LCJ1Ij" + - "|http://server/$/uuid0/2/2?h=oiL2RhdGEvZGF0YWJhc2UifQ==", - log); -}; - -ServerTest.prototype.testItShouldEncodeUsingUrlRules = function() { - var server = new Server("http://server"); - assertEquals("fn5-fn5-", server.base64url("~~~~~~")); - assertEquals("fn5_fn5_", server.base64url("~~\u007f~~\u007f")); -}; - -FrameServerTest = TestCase("FrameServerTest"); - -FrameServerTest.prototype = { - testRead:function(){ - var window = {name:'$DATASET:"MyData"'}; - var server = new FrameServer(window); - server.read(); - assertEquals("MyData", server.data); - }, - testWrite:function(){ - var window = {}; - var server = new FrameServer(window); - server.data = "TestData"; - server.write(); - assertEquals('$DATASET:"TestData"', window.name); - } -}; diff --git a/test/moveToAngularCom/UsersTest.js b/test/moveToAngularCom/UsersTest.js deleted file mode 100644 index f0ff545a..00000000 --- a/test/moveToAngularCom/UsersTest.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2008,2009 BRAT Tech LLC - -UsersTest = TestCase("UsersTest"); - -UsersTest.prototype = { - setUp:function(){}, - - tearDown:function(){}, - - testItShouldFetchCurrentUser:function(){ - expectAsserts(5); - var user; - var users = new Users({request:function(method, url, request, callback){ - assertEquals("GET", method); - assertEquals("/account.json", url); - assertEquals("{}", toJson(request)); - callback(200, {$status_code:200, user:{name:'misko'}}); - }}); - users.fetchCurrentUser(function(u){ - user = u; - assertEquals("misko", u.name); - assertEquals("misko", users.current.name); - }); - } - -}; -- cgit v1.2.3 From 8ddee9bb25ade2bbe7d57db6353b29867606c184 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 26 Jul 2010 16:11:25 -0700 Subject: add $exceptionHandler service --- test/servicesSpec.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/servicesSpec.js b/test/servicesSpec.js index 031c48f0..91538703 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -66,6 +66,15 @@ describe("service", function(){ }); }); + describe("$exceptionHandler", function(){ + it('should log errors', function(){ + var error = ''; + $log.error = function(m) { error += m; }; + scope.$exceptionHandler('myError'); + expect(error).toEqual('myError'); + }); + }); + describe("$location", function(){ it("should inject $location", function(){ scope.$location.parse('http://host:123/p/a/t/h.html?query=value#path?key=value'); -- cgit v1.2.3