diff options
| author | Kai Groner | 2012-01-19 22:39:32 -0500 | 
|---|---|---|
| committer | Igor Minar | 2012-01-24 10:28:29 -0800 | 
| commit | 56bcc04c54ed24c19204f68de52b8c30c00e08f0 (patch) | |
| tree | 5362e700f3d1c98231a97ebeddb6947ac9d49fdb /test/directivesSpec.js | |
| parent | b2052d08a151e81ed01b76a3b73add6e799c8133 (diff) | |
| download | angular.js-56bcc04c54ed24c19204f68de52b8c30c00e08f0.tar.bz2 | |
feat(ng:class): support using map of classnames and conditions
enables <div ng:class="{'hide': !visible, 'warning': isAlert()}"...
Diffstat (limited to 'test/directivesSpec.js')
| -rw-r--r-- | test/directivesSpec.js | 22 | 
1 files changed, 22 insertions, 0 deletions
| diff --git a/test/directivesSpec.js b/test/directivesSpec.js index 7600a9c8..e52d9fcb 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -200,6 +200,28 @@ describe("directive", function() {      })); +    it('should support adding multiple classes conditionally via a map of class names to boolean' + +        'expressions', inject(function($rootScope, $compile) { +      var element = $compile( +          '<div class="existing" ' + +              'ng:class="{A: conditionA, B: conditionB(), AnotB: conditionA&&!conditionB}">' + +          '</div>')($rootScope); +      $rootScope.conditionA = true; +      $rootScope.$digest(); +      expect(element.hasClass('existing')).toBeTruthy(); +      expect(element.hasClass('A')).toBeTruthy(); +      expect(element.hasClass('B')).toBeFalsy(); +      expect(element.hasClass('AnotB')).toBeTruthy(); + +      $rootScope.conditionB = function() { return true }; +      $rootScope.$digest(); +      expect(element.hasClass('existing')).toBeTruthy(); +      expect(element.hasClass('A')).toBeTruthy(); +      expect(element.hasClass('B')).toBeTruthy(); +      expect(element.hasClass('AnotB')).toBeFalsy(); +    })); + +      it('should support adding multiple classes via a space delimited string', inject(function($rootScope, $compile) {        var element = $compile('<div class="existing" ng:class="\'A B\'"></div>')($rootScope);        $rootScope.$digest(); | 
