diff options
| author | Misko Hevery | 2011-01-19 15:42:11 -0800 | 
|---|---|---|
| committer | Misko Hevery | 2011-01-24 14:23:51 -0800 | 
| commit | c2f2587a79aeb77aad66f081cf924a79348a698e (patch) | |
| tree | 8f5aa4cc6e7189befb834388b2102d1eda88a975 /test | |
| parent | 5d0d34ae72a9ca47f1b2dabda60711ad16ee9313 (diff) | |
| download | angular.js-c2f2587a79aeb77aad66f081cf924a79348a698e.tar.bz2 | |
fixed example rendering, add tests for it.
Diffstat (limited to 'test')
| -rw-r--r-- | test/AngularSpec.js | 10 | ||||
| -rw-r--r-- | test/BinderSpec.js | 238 | ||||
| -rw-r--r-- | test/CompilerSpec.js | 2 | ||||
| -rw-r--r-- | test/FiltersSpec.js | 10 | ||||
| -rw-r--r-- | test/FormattersSpec.js | 4 | ||||
| -rw-r--r-- | test/ParserSpec.js | 20 | ||||
| -rw-r--r-- | test/ScenarioSpec.js | 18 | ||||
| -rw-r--r-- | test/ScopeSpec.js | 4 | ||||
| -rw-r--r-- | test/ValidatorsSpec.js | 42 | ||||
| -rw-r--r-- | test/jquery_alias.js | 2 | ||||
| -rw-r--r-- | test/jquery_remove.js | 2 | ||||
| -rw-r--r-- | test/markupSpec.js | 2 | ||||
| -rw-r--r-- | test/sanitizerSpec.js | 22 | ||||
| -rw-r--r-- | test/scenario/mocks.js | 2 | ||||
| -rw-r--r-- | test/servicesSpec.js | 10 | 
15 files changed, 194 insertions, 194 deletions
| diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 0e6b2bfa..010dce7c 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -312,24 +312,24 @@ describe('angular service', function() {      var scope = createScope();      angular.service('fake', function() { return 'old'; });      angular.service('fake', function() { return 'new'; }); -     +      expect(scope.$service('fake')).toEqual('new');    }); -   +    it('should not preserve properties on override', function() {      angular.service('fake', {$one: true}, {$two: true}, {three: true});      var result = angular.service('fake', {$four: true}); -     +      expect(result.$one).toBeUndefined();      expect(result.$two).toBeUndefined();      expect(result.three).toBeUndefined();      expect(result.$four).toBe(true);    }); -   +    it('should not preserve non-angular properties on override', function() {      angular.service('fake', {one: true}, {two: true});      var result = angular.service('fake', {third: true}); -     +      expect(result.one).not.toBeDefined();      expect(result.two).not.toBeDefined();      expect(result.third).toBeTruthy(); diff --git a/test/BinderSpec.js b/test/BinderSpec.js index 33bcb091..f12c1a74 100644 --- a/test/BinderSpec.js +++ b/test/BinderSpec.js @@ -1,16 +1,16 @@  describe('Binder', function(){ -   +    beforeEach(function(){      var self = this; -   +      this.compile = function(html, initialScope, parent) {        var compiler = new Compiler(angularTextMarkup, angularAttrMarkup, angularDirective, angularWidget);        if (self.element) dealoc(self.element);        var element = self.element = jqLite(html);        var scope = compiler.compile(element)(element); -   +        if (parent) parent.append(element); -   +        extend(scope, initialScope);        scope.$init();        return {node:element, scope:scope}; @@ -19,48 +19,48 @@ describe('Binder', function(){        return sortedHtml(this.compile(content).node);      };    }); -   +    afterEach(function(){      if (this.element && this.element.dealoc) {        this.element.dealoc();      }    }); -   -   + +    it('ChangingTextfieldUpdatesModel', function(){      var state = this.compile('<input type="text" name="model.price" value="abc">', {model:{}});      state.scope.$eval();      assertEquals('abc', state.scope.model.price);    }); -   +    it('ChangingTextareaUpdatesModel', function(){      var c = this.compile('<textarea name="model.note">abc</textarea>');      c.scope.$eval();      assertEquals(c.scope.model.note, 'abc');    }); -   +    it('ChangingRadioUpdatesModel', function(){      var c = this.compile('<input type="radio" name="model.price" value="A" checked>' +            '<input type="radio" name="model.price" value="B">');      c.scope.$eval();      assertEquals(c.scope.model.price, 'A');    }); -   +    it('ChangingCheckboxUpdatesModel', function(){      var form = this.compile('<input type="checkbox" name="model.price" value="true" checked ng:format="boolean"/>');      assertEquals(true, form.scope.model.price);    }); -   +    it('BindUpdate', function(){      var c = this.compile('<div ng:eval="a=123"/>');      assertEquals(123, c.scope.$get('a'));    }); -   +    it('ChangingSelectNonSelectedUpdatesModel', function(){      var form = this.compile('<select name="model.price"><option value="A">A</option><option value="B">B</option></select>');      assertEquals('A', form.scope.model.price);    }); -   +    it('ChangingMultiselectUpdatesModel', function(){      var form = this.compile('<select name="Invoice.options" multiple="multiple">' +              '<option value="A" selected>Gift wrap</option>' + @@ -69,35 +69,35 @@ describe('Binder', function(){              '</select>');      assertJsonEquals(["A", "B"], form.scope.$get('Invoice').options);    }); -   +    it('ChangingSelectSelectedUpdatesModel', function(){      var form = this.compile('<select name="model.price"><option>A</option><option selected value="b">B</option></select>');      assertEquals(form.scope.model.price, 'b');    }); -   +    it('ExecuteInitialization', function(){      var c = this.compile('<div ng:init="a=123">');      assertEquals(c.scope.$get('a'), 123);    }); -   +    it('ExecuteInitializationStatements', function(){      var c = this.compile('<div ng:init="a=123;b=345">');      assertEquals(c.scope.$get('a'), 123);      assertEquals(c.scope.$get('b'), 345);    }); -   +    it('ApplyTextBindings', function(){      var form = this.compile('<div ng:bind="model.a">x</div>');      form.scope.$set('model', {a:123});      form.scope.$eval();      assertEquals('123', form.node.text());    }); -   +    it('ReplaceBindingInTextWithSpan', function(){      assertEquals(this.compileToHtml("<b>a{{b}}c</b>"), '<b>a<span ng:bind="b"></span>c</b>');      assertEquals(this.compileToHtml("<b>{{b}}</b>"), '<b><span ng:bind="b"></span></b>');    }); -   +    it('BindingSpaceConfusesIE', function(){      if (!msie) return;      var span = document.createElement("span"); @@ -110,7 +110,7 @@ describe('Binder', function(){          '<b><span ng:bind="A"></span><span>'+nbsp+'x </span><span ng:bind="B"></span><span>'+nbsp+'(</span><span ng:bind="C"></span>)</b>',          this.compileToHtml("<b>{{A}} x {{B}} ({{C}})</b>"));    }); -   +    it('BindingOfAttributes', function(){      var c = this.compile("<a href='http://s/a{{b}}c' foo='x'></a>");      var attrbinding = c.node.attr("ng:bind-attr"); @@ -118,7 +118,7 @@ describe('Binder', function(){      assertEquals("http://s/a{{b}}c", decodeURI(bindings.href));      assertTrue(!bindings.foo);    }); -   +    it('MarkMultipleAttributes', function(){      var c = this.compile('<a href="http://s/a{{b}}c" foo="{{d}}"></a>');      var attrbinding = c.node.attr("ng:bind-attr"); @@ -126,20 +126,20 @@ describe('Binder', function(){      assertEquals(bindings.foo, "{{d}}");      assertEquals(decodeURI(bindings.href), "http://s/a{{b}}c");    }); -   +    it('AttributesNoneBound', function(){      var c = this.compile("<a href='abc' foo='def'></a>");      var a = c.node;      assertEquals(a[0].nodeName, "A");      assertTrue(!a.attr("ng:bind-attr"));    }); -   +    it('ExistingAttrbindingIsAppended', function(){      var c = this.compile("<a href='http://s/{{abc}}' ng:bind-attr='{\"b\":\"{{def}}\"}'></a>");      var a = c.node;      assertEquals('{"b":"{{def}}","href":"http://s/{{abc}}"}', a.attr('ng:bind-attr'));    }); -   +    it('AttributesAreEvaluated', function(){      var c = this.compile('<a ng:bind-attr=\'{"a":"a", "b":"a+b={{a+b}}"}\'></a>');      var binder = c.binder, form = c.node; @@ -149,7 +149,7 @@ describe('Binder', function(){      assertEquals(a.attr('a'), 'a');      assertEquals(a.attr('b'), 'a+b=3');    }); -   +    it('InputTypeButtonActionExecutesInScope', function(){      var savedCalled = false;      var c = this.compile('<input type="button" ng:click="person.save()" value="Apply">'); @@ -159,7 +159,7 @@ describe('Binder', function(){      browserTrigger(c.node, 'click');      assertTrue(savedCalled);    }); -   +    it('InputTypeButtonActionExecutesInScope2', function(){      var log = "";      var c = this.compile('<input type="image" ng:click="action()">'); @@ -170,7 +170,7 @@ describe('Binder', function(){      browserTrigger(c.node, 'click');      expect(log).toEqual('click;');    }); -   +    it('ButtonElementActionExecutesInScope', function(){      var savedCalled = false;      var c = this.compile('<button ng:click="person.save()">Apply</button>'); @@ -180,20 +180,20 @@ describe('Binder', function(){      browserTrigger(c.node, 'click');      assertTrue(savedCalled);    }); -   +    it('RepeaterUpdateBindings', function(){      var a = this.compile('<ul><LI ng:repeat="item in model.items" ng:bind="item.a"/></ul>');      var form = a.node;      var items = [{a:"A"}, {a:"B"}];      a.scope.$set('model', {items:items}); -   +      a.scope.$eval();      assertEquals('<ul>' +            '<#comment></#comment>' +            '<li ng:bind="item.a" ng:repeat-index="0">A</li>' +            '<li ng:bind="item.a" ng:repeat-index="1">B</li>' +            '</ul>', sortedHtml(form)); -   +      items.unshift({a:'C'});      a.scope.$eval();      assertEquals('<ul>' + @@ -202,7 +202,7 @@ describe('Binder', function(){            '<li ng:bind="item.a" ng:repeat-index="1">A</li>' +            '<li ng:bind="item.a" ng:repeat-index="2">B</li>' +            '</ul>', sortedHtml(form)); -   +      items.shift();      a.scope.$eval();      assertEquals('<ul>' + @@ -210,12 +210,12 @@ describe('Binder', function(){            '<li ng:bind="item.a" ng:repeat-index="0">A</li>' +            '<li ng:bind="item.a" ng:repeat-index="1">B</li>' +            '</ul>', sortedHtml(form)); -   +      items.shift();      items.shift();      a.scope.$eval();    }); -   +    it('RepeaterContentDoesNotBind', function(){      var a = this.compile('<ul><LI ng:repeat="item in model.items"><span ng:bind="item.a"></span></li></ul>');      a.scope.$set('model', {items:[{a:"A"}]}); @@ -225,18 +225,18 @@ describe('Binder', function(){            '<li ng:repeat-index="0"><span ng:bind="item.a">A</span></li>' +            '</ul>', sortedHtml(a.node));    }); -   +    it('ExpandEntityTag', function(){      assertEquals(          '<div ng-entity="Person" ng:watch="$anchor.a:1"></div>',          this.compileToHtml('<div ng-entity="Person" ng:watch="$anchor.a:1"/>'));    }); -   +    it('DoNotOverwriteCustomAction', function(){      var html = this.compileToHtml('<input type="submit" value="Save" action="foo();">');      assertTrue(html.indexOf('action="foo();"') > 0 );    }); -   +    it('RepeaterAdd', function(){      var c = this.compile('<div><input type="text" name="item.x" ng:repeat="item in items"></div>');      var doc = c.node; @@ -246,81 +246,81 @@ describe('Binder', function(){      var second = childNode(c.node, 2);      assertEquals('a', first.val());      assertEquals('b', second.val()); -   +      first.val('ABC');      browserTrigger(first, 'keydown');      c.scope.$service('$browser').defer.flush();      assertEquals(c.scope.items[0].x, 'ABC');    }); -   +    it('ItShouldRemoveExtraChildrenWhenIteratingOverHash', function(){      var c = this.compile('<div><div ng:repeat="i in items">{{i}}</div></div>');      var items = {};      c.scope.$set("items", items); -   +      c.scope.$eval();      expect(c.node[0].childNodes.length - 1).toEqual(0); -   +      items.name = "misko";      c.scope.$eval();      expect(c.node[0].childNodes.length - 1).toEqual(1); -   +      delete items.name;      c.scope.$eval();      expect(c.node[0].childNodes.length - 1).toEqual(0);    }); -   +    it('IfTextBindingThrowsErrorDecorateTheSpan', function(){      var a = this.compile('<div>{{error.throw()}}</div>');      var doc = a.node; -   +      a.scope.$set('error.throw', function(){throw "ErrorMsg1";});      a.scope.$eval();      var span = childNode(doc, 0);      assertTrue(span.hasClass('ng-exception'));      assertTrue(!!span.text().match(/ErrorMsg1/));      assertTrue(!!span.attr('ng-exception').match(/ErrorMsg1/)); -   +      a.scope.$set('error.throw', function(){throw "MyError";});      a.scope.$eval();      span = childNode(doc, 0);      assertTrue(span.hasClass('ng-exception'));      assertTrue(span.text(), span.text().match('MyError') !== null);      assertEquals('MyError', span.attr('ng-exception')); -   +      a.scope.$set('error.throw', function(){return "ok";});      a.scope.$eval();      assertFalse(span.hasClass('ng-exception'));      assertEquals('ok', span.text());      assertEquals(null, span.attr('ng-exception'));    }); -   +    it('IfAttrBindingThrowsErrorDecorateTheAttribute', function(){      var a = this.compile('<div attr="before {{error.throw()}} after"></div>');      var doc = a.node; -   +      a.scope.$set('error.throw', function(){throw "ErrorMsg";});      a.scope.$eval();      assertTrue('ng-exception', doc.hasClass('ng-exception'));      assertEquals('"ErrorMsg"', doc.attr('ng-exception'));      assertEquals('before "ErrorMsg" after', doc.attr('attr')); -   +      a.scope.$set('error.throw', function(){ return 'X';});      a.scope.$eval();      assertFalse('!ng-exception', doc.hasClass('ng-exception'));      assertEquals('before X after', doc.attr('attr'));      assertEquals(null, doc.attr('ng-exception')); -   +    }); -   +    it('NestedRepeater', function(){      var a = this.compile('<div><div ng:repeat="m in model" name="{{m.name}}">' +                       '<ul name="{{i}}" ng:repeat="i in m.item"></ul>' +                     '</div></div>'); -   +      a.scope.$set('model', [{name:'a', item:['a1', 'a2']}, {name:'b', item:['b1', 'b2']}]);      a.scope.$eval(); -   +      assertEquals('<div>'+          '<#comment></#comment>'+          '<div name="a" ng:bind-attr="{"name":"{{m.name}}"}" ng:repeat-index="0">'+ @@ -334,82 +334,82 @@ describe('Binder', function(){            '<ul name="b2" ng:bind-attr="{"name":"{{i}}"}" ng:repeat-index="1"></ul>'+          '</div></div>', sortedHtml(a.node));    }); -   +    it('HideBindingExpression', function(){      var a = this.compile('<div ng:hide="hidden == 3"/>'); -   +      a.scope.$set('hidden', 3);      a.scope.$eval(); -   +      assertHidden(a.node); -   +      a.scope.$set('hidden', 2);      a.scope.$eval(); -   +      assertVisible(a.node);    }); -   +    it('HideBinding', function(){      var c = this.compile('<div ng:hide="hidden"/>'); -   +      c.scope.$set('hidden', 'true');      c.scope.$eval(); -   +      assertHidden(c.node); -   +      c.scope.$set('hidden', 'false');      c.scope.$eval(); -   +      assertVisible(c.node); -   +      c.scope.$set('hidden', '');      c.scope.$eval(); -   +      assertVisible(c.node);    }); -   +    it('ShowBinding', function(){      var c = this.compile('<div ng:show="show"/>'); -   +      c.scope.$set('show', 'true');      c.scope.$eval(); -   +      assertVisible(c.node); -   +      c.scope.$set('show', 'false');      c.scope.$eval(); -   +      assertHidden(c.node); -   +      c.scope.$set('show', '');      c.scope.$eval(); -   +      assertHidden(c.node);    }); -   +    it('BindClassUndefined', function(){      var doc = this.compile('<div ng:class="undefined"/>');      doc.scope.$eval(); -   +      assertEquals(          '<div class="undefined" ng:class="undefined"></div>',          sortedHtml(doc.node));    }); -   +    it('BindClass', function(){      var c = this.compile('<div ng:class="class"/>'); -   +      c.scope.$set('class', 'testClass');      c.scope.$eval(); -   +      assertEquals('<div class="testClass" ng:class="class"></div>', sortedHtml(c.node)); -   +      c.scope.$set('class', ['a', 'b']);      c.scope.$eval(); -   +      assertEquals('<div class="a b" ng:class="class"></div>', sortedHtml(c.node));    }); -   +    it('BindClassEvenOdd', function(){      var x = this.compile('<div><div ng:repeat="i in [0,1]" ng:class-even="\'e\'" ng:class-odd="\'o\'"/></div>');      x.scope.$eval(); @@ -423,19 +423,19 @@ describe('Binder', function(){          '<div class="e" ng:class-even="\'e\'" ng:class-odd="\'o\'" ng:repeat-index="1"></div></div>',          sortedHtml(x.node));    }); -   +    it('BindStyle', function(){      var c = this.compile('<div ng:style="style"/>'); -   +      c.scope.$eval('style={color:"red"}');      c.scope.$eval(); -   +      assertEquals("red", c.node.css('color')); -   +      c.scope.$eval('style={}');      c.scope.$eval();    }); -   +    it('ActionOnAHrefThrowsError', function(){      var model = {books:[]};      var c = this.compile('<a ng:click="action()">Add Phone</a>', model); @@ -447,14 +447,14 @@ describe('Binder', function(){      var error = input.attr('ng-exception');      assertTrue(!!error.match(/MyError/));      assertTrue("should have an error class", input.hasClass('ng-exception')); -   +      // TODO: I think that exception should never get cleared so this portion of test makes no sense      //c.scope.action = noop;      //browserTrigger(input, 'click');      //dump(input.attr('ng-error'));      //assertFalse('error class should be cleared', input.hasClass('ng-exception'));    }); -   +    it('ShoulIgnoreVbNonBindable', function(){      var c = this.compile("<div>{{a}}" +          "<div ng:non-bindable>{{a}}</div>" + @@ -464,31 +464,31 @@ describe('Binder', function(){      c.scope.$eval();      assertEquals('123{{a}}{{b}}{{c}}', c.node.text());    }); -   +    it('OptionShouldUpdateParentToGetProperBinding', function(){      var c = this.compile('<select name="s"><option ng:repeat="i in [0,1]" value="{{i}}" ng:bind="i"></option></select>');      c.scope.$set('s', 1);      c.scope.$eval();      assertEquals(1, c.node[0].selectedIndex);    }); -   +    it('RepeaterShouldBindInputsDefaults', function () {      var c = this.compile('<div><input value="123" name="item.name" ng:repeat="item in items"></div>');      c.scope.$set('items', [{}, {name:'misko'}]);      c.scope.$eval(); -   +      assertEquals("123", c.scope.$eval('items[0].name'));      assertEquals("misko", c.scope.$eval('items[1].name'));    }); -   +    it('ShouldTemplateBindPreElements', function () {      var c = this.compile('<pre>Hello {{name}}!</pre>');      c.scope.$set("name", "World");      c.scope.$eval(); -   +      assertEquals('<pre ng:bind-template="Hello {{name}}!">Hello World!</pre>', sortedHtml(c.node));    }); -   +    it('FillInOptionValueWhenMissing', function(){      var c = this.compile(          '<select><option selected="true">{{a}}</option><option value="">{{b}}</option><option>C</option></select>'); @@ -498,17 +498,17 @@ describe('Binder', function(){      var optionA = childNode(c.node, 0);      var optionB = childNode(c.node, 1);      var optionC = childNode(c.node, 2); -   +      expect(optionA.attr('value')).toEqual('A');      expect(optionA.text()).toEqual('A'); -   +      expect(optionB.attr('value')).toEqual('');      expect(optionB.text()).toEqual('B'); -   +      expect(optionC.attr('value')).toEqual('C');      expect(optionC.text()).toEqual('C');    }); -   +    it('ValidateForm', function(){      var c = this.compile('<div><input name="name" ng:required>' +              '<div ng:repeat="item in items"><input name="item.name" ng:required/></div></div>', @@ -517,39 +517,39 @@ describe('Binder', function(){      c.scope.$set("items", items);      c.scope.$eval();      assertEquals(3, c.scope.$service('$invalidWidgets').length); -   +      c.scope.$set('name', '');      c.scope.$eval();      assertEquals(3, c.scope.$service('$invalidWidgets').length); -   +      c.scope.$set('name', ' ');      c.scope.$eval();      assertEquals(3, c.scope.$service('$invalidWidgets').length); -   +      c.scope.$set('name', 'abc');      c.scope.$eval();      assertEquals(2, c.scope.$service('$invalidWidgets').length); -   +      items[0].name = 'abc';      c.scope.$eval();      assertEquals(1, c.scope.$service('$invalidWidgets').length); -   +      items[1].name = 'abc';      c.scope.$eval();      assertEquals(0, c.scope.$service('$invalidWidgets').length);    }); -   +    it('ValidateOnlyVisibleItems', function(){      var c = this.compile('<div><input name="name" ng:required><input ng:show="show" name="name" ng:required></div>', undefined, jqLite(document.body));      c.scope.$set("show", true);      c.scope.$eval();      assertEquals(2, c.scope.$service('$invalidWidgets').length); -   +      c.scope.$set("show", false);      c.scope.$eval();      assertEquals(1, c.scope.$service('$invalidWidgets').visible());    }); -   +    it('DeleteAttributeIfEvaluatesFalse', function(){      var c = this.compile('<div>' +          '<input name="a0" ng:bind-attr="{disabled:\'{{true}}\'}"><input name="a1" ng:bind-attr="{disabled:\'{{false}}\'}">' + @@ -560,7 +560,7 @@ describe('Binder', function(){        var child = childNode(c.node, index);        assertEquals(sortedHtml(child), disabled, !!child.attr('disabled'));      } -   +      assertChild(0, true);      assertChild(1, false);      assertChild(2, true); @@ -568,41 +568,41 @@ describe('Binder', function(){      assertChild(4, true);      assertChild(5, false);    }); -   +    it('ItShouldDisplayErrorWhenActionIsSyntacticlyIncorect', function(){      var c = this.compile('<div>' +          '<input type="button" ng:click="greeting=\'ABC\'"/>' +          '<input type="button" ng:click=":garbage:"/></div>');      var first = jqLite(c.node[0].childNodes[0]);      var second = jqLite(c.node[0].childNodes[1]); -   +      browserTrigger(first, 'click');      assertEquals("ABC", c.scope.greeting); -   +      browserTrigger(second, 'click');      assertTrue(second.hasClass("ng-exception"));    }); -   +    it('ItShouldSelectTheCorrectRadioBox', function(){      var c = this.compile('<div>' +          '<input type="radio" name="sex" value="female"/>' +          '<input type="radio" name="sex" value="male"/></div>');      var female = jqLite(c.node[0].childNodes[0]);      var male = jqLite(c.node[0].childNodes[1]); -   +      browserTrigger(female);      assertEquals("female", c.scope.sex);      assertEquals(true, female[0].checked);      assertEquals(false, male[0].checked);      assertEquals("female", female.val()); -   +      browserTrigger(male);      assertEquals("male", c.scope.sex);      assertEquals(false, female[0].checked);      assertEquals(true, male[0].checked);      assertEquals("male", male.val());    }); -   +    it('ItShouldListenOnRightScope', function(){      var c = this.compile(          '<ul ng:init="counter=0; gCounter=0" ng:watch="w:counter=counter+1">' + @@ -610,13 +610,13 @@ describe('Binder', function(){      c.scope.$eval();      assertEquals(1, c.scope.$get("counter"));      assertEquals(7, c.scope.$get("gCounter")); -   +      c.scope.$set("w", "something");      c.scope.$eval();      assertEquals(2, c.scope.$get("counter"));      assertEquals(14, c.scope.$get("gCounter"));    }); -   +    it('ItShouldRepeatOnHashes', function(){      var x = this.compile('<ul><li ng:repeat="(k,v) in {a:0,b:1}" ng:bind=\"k + v\"></li></ul>');      x.scope.$eval(); @@ -627,7 +627,7 @@ describe('Binder', function(){          '</ul>',          sortedHtml(x.node));    }); -   +    it('ItShouldFireChangeListenersBeforeUpdate', function(){      var x = this.compile('<div ng:bind="name"></div>');      x.scope.$set("name", ""); @@ -639,19 +639,19 @@ describe('Binder', function(){          '<div ng:bind="name">123</div>',          sortedHtml(x.node));    }); -   +    it('ItShouldHandleMultilineBindings', function(){      var x = this.compile('<div>{{\n 1 \n + \n 2 \n}}</div>');      x.scope.$eval();      assertEquals("3", x.node.text());    }); -   +    it('ItBindHiddenInputFields', function(){      var x = this.compile('<input type="hidden" name="myName" value="abc" />');      x.scope.$eval();      assertEquals("abc", x.scope.$get("myName"));    }); -     +    it('ItShouldUseFormaterForText', function(){      var x = this.compile('<input name="a" ng:format="list" value="a,b">');      x.scope.$eval(); @@ -665,4 +665,4 @@ describe('Binder', function(){      assertEquals('1, 2, 3', input[0].value);    }); -});
\ No newline at end of file +}); diff --git a/test/CompilerSpec.js b/test/CompilerSpec.js index 76d3d1ca..498ee060 100644 --- a/test/CompilerSpec.js +++ b/test/CompilerSpec.js @@ -32,7 +32,7 @@ describe('compiler', function(){        return scope;      };    }); -   +    afterEach(function(){      dealoc(scope);    }); diff --git a/test/FiltersSpec.js b/test/FiltersSpec.js index 7e824e0d..092f9b7b 100644 --- a/test/FiltersSpec.js +++ b/test/FiltersSpec.js @@ -1,17 +1,17 @@  describe('filter', function() {    var filter = angular.filter; -   +    it('should called the filter when evaluating expression', function() {      var scope = createScope();      filter.fakeFilter = function(){};      spyOn(filter, 'fakeFilter'); -     +      scope.$eval('10|fakeFilter');      expect(filter.fakeFilter).toHaveBeenCalledWith(10);      delete filter['fakeFilter'];    }); -   +    it('should call filter on scope context', function() {      var scope = createScope();      scope.name = 'misko'; @@ -19,7 +19,7 @@ describe('filter', function() {        expect(this.name).toEqual('misko');      };      spyOn(filter, 'fakeFilter').andCallThrough(); -     +      scope.$eval('10|fakeFilter');      expect(filter.fakeFilter).toHaveBeenCalled();      delete filter['fakeFilter']; @@ -39,7 +39,7 @@ describe('filter', function() {        expect(html.hasClass('ng-format-negative')).toBeFalsy();      });    }); -   +    describe('number', function() {      it('should do basic filter', function() {        var context = {jqElement:jqLite('<span/>')}; diff --git a/test/FormattersSpec.js b/test/FormattersSpec.js index 1ebd8e22..234a81d6 100644 --- a/test/FormattersSpec.js +++ b/test/FormattersSpec.js @@ -33,13 +33,13 @@ describe("formatter", function(){      assertEquals('a', angular.formatter.trim.format(" a "));      assertEquals('a', angular.formatter.trim.parse(' a '));    }); -   +    describe('json', function(){      it('should treat empty string as null', function(){        expect(angular.formatter.json.parse('')).toEqual(null);      });    }); -   +    describe('index', function(){      it('should parse an object from array', function(){        expect(angular.formatter.index.parse('1', ['A', 'B', 'C'])).toEqual('B'); diff --git a/test/ParserSpec.js b/test/ParserSpec.js index 4d0e14dc..62d6731a 100644 --- a/test/ParserSpec.js +++ b/test/ParserSpec.js @@ -58,7 +58,7 @@ describe('parser', function() {        expect(tokens[i].text).toEqual('undefined');        expect(undefined).toEqual(tokens[i].fn());      }); -     +      it('should tokenize quoted string', function() {        var str = "['\\'', \"\\\"\"]";        var tokens = lex(str); @@ -134,7 +134,7 @@ describe('parser', function() {        expect(function() {          lex("0.5E-");        }).toThrow(new Error('Lexer Error: Invalid exponent at column 4 in expression [0.5E-].')); -       +        expect(function() {          lex("0.5E-A");        }).toThrow(new Error('Lexer Error: Invalid exponent at column 4 in expression [0.5E-A].')); @@ -151,7 +151,7 @@ describe('parser', function() {        }).toThrow(new Error("Lexer Error: Invalid unicode escape [\\u1''b] at column 2 in expression ['\\u1''bla']."));      });    }); -   +    var scope;    beforeEach(function () {      scope = createScope(); @@ -201,7 +201,7 @@ describe('parser', function() {      expect(function() {        scope.$eval("1|nonExistant");      }).toThrow(new Error("Parse Error: Token 'nonExistant' should be a function at column 3 of expression [1|nonExistant] starting at [nonExistant].")); -     +      scope.$set('offset', 3);      expect(scope.$eval("'abcd'|upper._case")).toEqual("ABCD");      expect(scope.$eval("'abcd'|substring:1:offset")).toEqual("bc"); @@ -298,7 +298,7 @@ describe('parser', function() {      scope.$set("obj", new C());      expect(scope.$eval("obj.getA()")).toEqual(123);    }); -   +    it('should evaluate methods in correct context (this) in argument', function() {      var C = function () {        this.a = 123; @@ -388,7 +388,7 @@ describe('parser', function() {      expect(scope.$eval("a=undefined")).not.toBeDefined();      expect(scope.$get("a")).not.toBeDefined();    }); -   +    it('should allow assignment after array dereference', function(){      scope = angular.scope();      scope.obj = [{}]; @@ -396,21 +396,21 @@ describe('parser', function() {      expect(scope.obj.name).toBeUndefined();      expect(scope.obj[0].name).toEqual(1);    }); -   +    describe('formatter', function(){      it('should return no argument function', function() {        var noop = parser('noop').formatter()();        expect(noop.format(null, 'abc')).toEqual('abc');        expect(noop.parse(null, '123')).toEqual('123');      }); -     +      it('should delegate arguments', function(){        var index = parser('index:objs').formatter()();        expect(index.format({objs:['A','B']}, 'B')).toEqual('1');        expect(index.parse({objs:['A','B']}, '1')).toEqual('B');      });    }); -   +    describe('assignable', function(){      it('should expose assignment function', function(){        var fn = parser('a').assignable(); @@ -420,5 +420,5 @@ describe('parser', function() {        expect(scope).toEqual({a:123});      });    }); -   +  }); diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js index 30a3d72a..50b5e51c 100644 --- a/test/ScenarioSpec.js +++ b/test/ScenarioSpec.js @@ -1,14 +1,14 @@  describe("ScenarioSpec: Compilation", function(){    var scope; -   +    beforeEach(function(){      scope = null;    }); -   +    afterEach(function(){      dealoc(scope);    }); -   +    describe('compilation', function(){      it("should compile dom node and return scope", function(){        var node = jqLite('<div ng:init="a=1">{{b=a+1}}</div>')[0]; @@ -17,18 +17,18 @@ describe("ScenarioSpec: Compilation", function(){        expect(scope.a).toEqual(1);        expect(scope.b).toEqual(2);      }); -     +      it("should compile jQuery node and return scope", function(){        scope = compile(jqLite('<div>{{a=123}}</div>')).$init();        expect(jqLite(scope.$element).text()).toEqual('123');      }); -     +      it("should compile text node and return scope", function(){        scope = compile('<div>{{a=123}}</div>').$init();        expect(jqLite(scope.$element).text()).toEqual('123');      });    }); -   +    describe('scope', function(){      it("should have set, get, eval, $init, updateView methods", function(){        scope = compile('<div>{{a}}</div>').$init(); @@ -39,7 +39,7 @@ describe("ScenarioSpec: Compilation", function(){        scope.$eval();        expect(jqLite(scope.$element).text()).toEqual('3');      }); -     +      it("should have $ objects", function(){        scope = compile('<div></div>', {$config: {a:"b"}});        expect(scope.$service('$location')).toBeDefined(); @@ -48,7 +48,7 @@ describe("ScenarioSpec: Compilation", function(){        expect(scope.$get('$config.a')).toEqual("b");      });    }); -   +    describe("configuration", function(){      it("should take location object", function(){        var url = "http://server/#?book=moby"; @@ -61,4 +61,4 @@ describe("ScenarioSpec: Compilation", function(){        expect($location.hashSearch.book).toEqual('moby');      });    }); -});
\ No newline at end of file +}); diff --git a/test/ScopeSpec.js b/test/ScopeSpec.js index 354ddc72..ee7c1c47 100644 --- a/test/ScopeSpec.js +++ b/test/ScopeSpec.js @@ -52,7 +52,7 @@ describe('scope/model', function(){        model.$eval('name="works"');        expect(model.name).toEqual('works');      }); -     +      it('should not bind regexps', function(){        model.exp = /abc/;        expect(model.$eval('exp')).toEqual(model.exp); @@ -158,7 +158,7 @@ describe('scope/model', function(){        var element = jqLite('<div></div>');        var scope = createScope();        scope.$tryEval(function(){throw "myError";}, element); -      expect(element.attr('ng-exception')).toEqual('myError');  +      expect(element.attr('ng-exception')).toEqual('myError');        expect(element.hasClass('ng-exception')).toBeTruthy();      }); diff --git a/test/ValidatorsSpec.js b/test/ValidatorsSpec.js index ffd65c5b..60d20418 100644 --- a/test/ValidatorsSpec.js +++ b/test/ValidatorsSpec.js @@ -1,5 +1,5 @@  describe('ValidatorTest', function(){ -   +    it('ShouldHaveThisSet', function() {      var validator = {};      angular.validator.myValidator = function(first, last){ @@ -16,7 +16,7 @@ describe('ValidatorTest', function(){      delete angular.validator.myValidator;      scope.$element.remove();    }); -   +    it('Regexp', function() {      assertEquals(angular.validator.regexp("abc", /x/, "E1"), "E1");      assertEquals(angular.validator.regexp("abc", '/x/'), @@ -24,7 +24,7 @@ describe('ValidatorTest', function(){      assertEquals(angular.validator.regexp("ab", '^ab$'), null);      assertEquals(angular.validator.regexp("ab", '^axb$', "E3"), "E3");    }); -   +    it('Number', function() {      assertEquals(angular.validator.number("ab"), "Not a number");      assertEquals(angular.validator.number("-0.1",0), "Value can not be less than 0."); @@ -32,7 +32,7 @@ describe('ValidatorTest', function(){      assertEquals(angular.validator.number("1.2"), null);      assertEquals(angular.validator.number(" 1 ", 1, 1), null);    }); -   +    it('Integer', function() {      assertEquals(angular.validator.integer("ab"), "Not a number");      assertEquals(angular.validator.integer("1.1"), "Not a whole number"); @@ -43,7 +43,7 @@ describe('ValidatorTest', function(){      assertEquals(angular.validator.integer("1"), null);      assertEquals(angular.validator.integer(" 1 ", 1, 1), null);    }); -   +    it('Date', function() {      var error = "Value is not a date. (Expecting format: 12/31/2009).";      expect(angular.validator.date("ab")).toEqual(error); @@ -60,7 +60,7 @@ describe('ValidatorTest', function(){      expect(angular.validator.date("1/32/2010")).toEqual(error);      expect(angular.validator.date("001/031/2009")).toEqual(error);    }); -   +    it('Phone', function() {      var error = "Phone number needs to be in 1(987)654-3210 format in North America or +999 (123) 45678 906 internationaly.";      assertEquals(angular.validator.phone("ab"), error); @@ -68,30 +68,30 @@ describe('ValidatorTest', function(){      assertEquals(null, angular.validator.phone("+421 (0905) 933 297"));      assertEquals(null, angular.validator.phone("+421 0905 933 297"));    }); -   +    it('URL', function() {      var error = "URL needs to be in http://server[:port]/path format.";      assertEquals(angular.validator.url("ab"), error);      assertEquals(angular.validator.url("http://server:123/path"), null);    }); -   +    it('Email', function() {      var error = "Email needs to be in username@host.com format.";      assertEquals(error, angular.validator.email("ab"));      assertEquals(null, angular.validator.email("misko@hevery.com"));    }); -   +    it('Json', function() {      assertNotNull(angular.validator.json("'"));      assertNotNull(angular.validator.json("''X"));      assertNull(angular.validator.json("{}"));    }); -   +    describe('asynchronous', function(){      var asynchronous = angular.validator.asynchronous;      var self;      var value, fn; -   +      beforeEach(function(){        value = null;        fn = null; @@ -101,11 +101,11 @@ describe('ValidatorTest', function(){        self.$root = self;        self.$init();      }); -   +      afterEach(function(){        if (self.$element) self.$element.remove();      }); -   +      it('should make a request and show spinner', function(){        var value, fn;        var scope = compile('<input type="text" name="name" ng:validate="asynchronous:asyncFn"/>'); @@ -124,32 +124,32 @@ describe('ValidatorTest', function(){        expect(input.attr(NG_VALIDATION_ERROR)).toEqual("myError");        scope.$element.remove();      }); -   +      it("should not make second request to same value", function(){        asynchronous.call(self, "kai", function(v,f){value=v; fn=f;});        expect(value).toEqual('kai');        expect(self.$service('$invalidWidgets')[0]).toEqual(self.$element); -   +        var spy = jasmine.createSpy();        asynchronous.call(self, "kai", spy);        expect(spy).wasNotCalled(); -   +        asynchronous.call(self, "misko", spy);        expect(spy).wasCalled();      }); -   +      it("should ignore old callbacks, and not remove spinner", function(){        var firstCb, secondCb;        asynchronous.call(self, "first", function(v,f){value=v; firstCb=f;});        asynchronous.call(self, "second", function(v,f){value=v; secondCb=f;}); -   +        firstCb();        expect(self.$element.hasClass('ng-input-indicator-wait')).toBeTruthy(); -   +        secondCb();        expect(self.$element.hasClass('ng-input-indicator-wait')).toBeFalsy();      }); -   +      it("should handle update function", function(){        var scope = angular.compile('<input name="name" ng:validate="asynchronous:asyncFn:updateFn"/>');        scope.asyncFn = jasmine.createSpy(); @@ -165,6 +165,6 @@ describe('ValidatorTest', function(){        expect(scope.updateFn.mostRecentCall.args[0]).toEqual({id: 1234, data:'data'});        scope.$element.remove();      }); -   +    });  }); diff --git a/test/jquery_alias.js b/test/jquery_alias.js index 4b3fad00..0d884a39 100644 --- a/test/jquery_alias.js +++ b/test/jquery_alias.js @@ -1 +1 @@ -var _jQuery = jQuery;
\ No newline at end of file +var _jQuery = jQuery; diff --git a/test/jquery_remove.js b/test/jquery_remove.js index 5283c340..9e717240 100644 --- a/test/jquery_remove.js +++ b/test/jquery_remove.js @@ -1 +1 @@ -var _jQuery = jQuery.noConflict(true);
\ No newline at end of file +var _jQuery = jQuery.noConflict(true); diff --git a/test/markupSpec.js b/test/markupSpec.js index 3234bf2f..f78112d7 100644 --- a/test/markupSpec.js +++ b/test/markupSpec.js @@ -147,6 +147,6 @@ describe("markups", function(){      assertTrue(!hasBindings(parseBindings("a")));      assertTrue(hasBindings(parseBindings("{{b}}x{{c}}")));    }); -   +  }); diff --git a/test/sanitizerSpec.js b/test/sanitizerSpec.js index 3ad6c1c9..57eedec9 100644 --- a/test/sanitizerSpec.js +++ b/test/sanitizerSpec.js @@ -50,11 +50,11 @@ describe('HTML', function(){    });    it('should handle entities', function(){ -    var everything = '<div rel="!@#$%^&*()_+-={}[]:";\'<>?,./`~ ħ">' +  +    var everything = '<div rel="!@#$%^&*()_+-={}[]:";\'<>?,./`~ ħ">' +      '!@#$%^&*()_+-={}[]:";\'<>?,./`~ ħ</div>';      expectHTML(everything).toEqual(everything);    }); -   +    it('should handle improper html', function(){      expectHTML('< div rel="</div>" alt=abc dir=\'"\' >text< /div>').        toEqual('<div rel="</div>" alt="abc" dir=""">text</div>'); @@ -64,19 +64,19 @@ describe('HTML', function(){      expectHTML('< div rel="</div>" / >').        toEqual('<div rel="</div>"/>');    }); -   +    it('should ignore back slash as escape', function(){      expectHTML('<img alt="xxx\\" title="><script>....">').        toEqual('<img alt="xxx\\" title="><script>...."/>');    }); -   +    it('should ignore object attributes', function(){      expectHTML('<a constructor="hola">:)</a>').        toEqual('<a>:)</a>');      expectHTML('<constructor constructor="hola">:)</constructor>').        toEqual('');    }); -   +    describe('htmlSanitizerWriter', function(){      var writer, html;      beforeEach(function(){ @@ -118,13 +118,13 @@ describe('HTML', function(){        writer.start('div', {unknown:""});        expect(html).toEqual('<div>');      }); -     +      describe('explicitly dissallow', function(){        it('should not allow attributes', function(){          writer.start('div', {id:'a', name:'a', style:'a'});          expect(html).toEqual('<div>');        }); -       +        it('should not allow tags', function(){          function tag(name) {            writer.start(name, {}); @@ -149,13 +149,13 @@ describe('HTML', function(){          expect(html).toEqual('');        });      }); -     +      describe('isUri', function(){ -       +        function isUri(value) {          return value.match(URI_REGEXP);        } -       +        it('should be URI', function(){          expect(isUri('http://abc')).toBeTruthy();          expect(isUri('https://abc')).toBeTruthy(); @@ -163,7 +163,7 @@ describe('HTML', function(){          expect(isUri('mailto:me@example.com')).toBeTruthy();          expect(isUri('#anchor')).toBeTruthy();        }); -       +        it('should not be UIR', function(){          expect(isUri('')).toBeFalsy();          expect(isUri('javascript:alert')).toBeFalsy(); diff --git a/test/scenario/mocks.js b/test/scenario/mocks.js index 616e5d63..e023b6b0 100644 --- a/test/scenario/mocks.js +++ b/test/scenario/mocks.js @@ -32,7 +32,7 @@ angular.scenario.testing.MockRunner.prototype.on = function(eventName, fn) {    this.listeners[eventName] = this.listeners[eventName] || [];    this.listeners[eventName].push(fn);  }; -   +  angular.scenario.testing.MockRunner.prototype.emit = function(eventName) {    var args = Array.prototype.slice.call(arguments, 1);    angular.forEach(this.listeners[eventName] || [], function(fn) { diff --git a/test/servicesSpec.js b/test/servicesSpec.js index 0569c54a..e9b16621 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -60,7 +60,7 @@ describe("service", function(){        $log.info();        $log.error();      }); -     +      describe('Error', function(){        var e, $log, $console, errorArgs;        beforeEach(function(){ @@ -69,12 +69,12 @@ describe("service", function(){          e.sourceURL = undefined;          e.line = undefined;          e.stack = undefined; -         +          $console = angular.service('$log')({console:{error:function(){            errorArgs = arguments;          }}});        }); -       +        it('should pass error if does not have trace', function(){          $console.error('abc', e);          expect(errorArgs).toEqual(['abc', e]); @@ -93,9 +93,9 @@ describe("service", function(){          $console.error('abc', e);          expect(errorArgs).toEqual(['abc', 'message\nsourceURL:123']);        }); -       +      }); -     +    });    describe("$exceptionHandler", function(){ | 
