aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/directive/ngClassSpec.js
diff options
context:
space:
mode:
authorpetrovalex2012-08-14 22:45:01 +0300
committerMisko Hevery2012-09-06 16:06:22 -0700
commit6c67719dfa6ff3f2a15a8e1e7660cf2e6e9155b0 (patch)
tree8b5cdfe96fbfe01001117bc15f9b27bfeabef7a8 /test/ng/directive/ngClassSpec.js
parentcebd015f78c5e21bd37d4bc055dbcdc21dac2ef2 (diff)
downloadangular.js-6c67719dfa6ff3f2a15a8e1e7660cf2e6e9155b0.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.js44
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();
+ }));
});