diff options
| author | petrovalex | 2012-08-14 22:45:01 +0300 |
|---|---|---|
| committer | Misko Hevery | 2012-09-06 15:49:48 -0700 |
| commit | a56aaa9877d90c7ea6715b4647c1b7b8c6f8e7fd (patch) | |
| tree | 249f7a6c1d1f87de7ba45b14f36bc9002a691564 /test/ng/directive/ngClassSpec.js | |
| parent | 79bb7b1f0b6ded0ca84660f387f406de98f5bdf1 (diff) | |
| download | angular.js-a56aaa9877d90c7ea6715b4647c1b7b8c6f8e7fd.tar.bz2 | |
fix(ngClassEven/Odd): filtering/ordering and repeater
Closes #1076
Diffstat (limited to 'test/ng/directive/ngClassSpec.js')
| -rw-r--r-- | test/ng/directive/ngClassSpec.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/ng/directive/ngClassSpec.js b/test/ng/directive/ngClassSpec.js index fc46bf7c..4a53030b 100644 --- a/test/ng/directive/ngClassSpec.js +++ b/test/ng/directive/ngClassSpec.js @@ -234,4 +234,48 @@ describe('ngClass', function() { expect(element.hasClass('two')).toBeFalsy(); expect(element.hasClass('too')).toBeFalsy(); })); + + + it('should update ngClassOdd/Even when model is changed by filtering', inject(function($rootScope, $compile) { + element = $compile('<ul>' + + '<li ng-repeat="i in items" ' + + 'ng-class-odd="\'odd\'" ng-class-even="\'even\'"></li>' + + '<ul>')($rootScope); + $rootScope.items = ['a','b','a']; + $rootScope.$digest(); + + $rootScope.items = ['a','a']; + $rootScope.$digest(); + + var e1 = jqLite(element[0].childNodes[1]); + var e2 = jqLite(element[0].childNodes[2]); + + expect(e1.hasClass('odd')).toBeTruthy(); + expect(e1.hasClass('even')).toBeFalsy(); + + expect(e2.hasClass('even')).toBeTruthy(); + expect(e2.hasClass('odd')).toBeFalsy(); + })); + + + it('should update ngClassOdd/Even when model is changed by sorting', inject(function($rootScope, $compile) { + element = $compile('<ul>' + + '<li ng-repeat="i in items" ' + + 'ng-class-odd="\'odd\'" ng-class-even="\'even\'">i</li>' + + '<ul>')($rootScope); + $rootScope.items = ['a','b']; + $rootScope.$digest(); + + $rootScope.items = ['b','a']; + $rootScope.$digest(); + + var e1 = jqLite(element[0].childNodes[1]); + var e2 = jqLite(element[0].childNodes[2]); + + expect(e1.hasClass('odd')).toBeTruthy(); + expect(e1.hasClass('even')).toBeFalsy(); + + expect(e2.hasClass('even')).toBeTruthy(); + expect(e2.hasClass('odd')).toBeFalsy(); + })); }); |
