diff options
| author | Misko Hevery | 2010-03-22 21:29:57 -0700 | 
|---|---|---|
| committer | Misko Hevery | 2010-03-22 21:29:57 -0700 | 
| commit | 6ff550cfa9524bbb124d10caf1fc13c911ab3b4b (patch) | |
| tree | d76902a8bd2bac2d2064daee7e605ed59e625179 /test/directivesSpec.js | |
| parent | a8227086748e37c31c1bb71dec50c96d63c45eef (diff) | |
| download | angular.js-6ff550cfa9524bbb124d10caf1fc13c911ab3b4b.tar.bz2 | |
all angular.js directives now work
Diffstat (limited to 'test/directivesSpec.js')
| -rw-r--r-- | test/directivesSpec.js | 45 | 
1 files changed, 44 insertions, 1 deletions
diff --git a/test/directivesSpec.js b/test/directivesSpec.js index 7e0446ef..d125d326 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -6,7 +6,7 @@ describe("directives", function(){      var compiler = new Compiler(angularMarkup, angularDirective, angularWidget);      compile = function(html) {        element = jqLite(html); -      var view = compiler.compile(element.element)(element.element); +      var view = compiler.compile(element)(element);        view.init();        return view.scope;      }; @@ -108,4 +108,47 @@ describe("directives", function(){      element.click();      expect(scope.get('clicked')).toEqual(true);    }); + +  it('should ng-class', function(){ +    var scope = compile('<div class="existing" ng-class="[\'A\', \'B\']"></div>'); +    scope.updateView(); +    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('<ul><li ng-repeat="i in [0,1]" class="existing" ng-class-odd="\'odd\'" ng-class-even="\'even\'"></li><ul>'); +    scope.updateView(); +    var e1 = jQuery(element.parent()[0]).find('li:first'); +    var e2 = jQuery(element.parent()[0]).find('li:last'); +    expect(e1.hasClass('existing')).toBeTruthy(); +    expect(e1.hasClass('even')).toBeTruthy(); +    expect(e2.hasClass('existing')).toBeTruthy(); +    expect(e2.hasClass('odd')).toBeTruthy(); +  }); + +  it('should ng-style', function(){ +    var scope = compile('<div ng-style="{color:\'red\'}"></div>'); +    scope.updateView(); +    expect(element.css('color')).toEqual('red'); +  }); + +  it('should ng-show', function(){ +    var scope = compile('<div ng-hide="hide"></div>'); +    scope.updateView(); +    expect(element.css('display')).toEqual(''); +    scope.set('hide', true); +    scope.updateView(); +    expect(element.css('display')).toEqual('none'); +  }); + +  it('should ng-hide', function(){ +    var scope = compile('<div ng-show="show"></div>'); +    scope.updateView(); +    expect(element.css('display')).toEqual('none'); +    scope.set('show', true); +    scope.updateView(); +    expect(element.css('display')).toEqual(''); +  });  });  | 
