aboutsummaryrefslogtreecommitdiffstats
path: root/test/directivesSpec.js
diff options
context:
space:
mode:
authorDi Peng2011-08-09 18:24:56 -0700
committerIgor Minar2011-08-19 00:14:05 -0700
commit6fb4bf4c543b3e48375221a9c5f1791af31a3ffc (patch)
tree4f1481287156ceb45972ed216b4d1fe29cf05cbd /test/directivesSpec.js
parentcc604b6e26e22c04ef64f077fd3177bbf60533f2 (diff)
downloadangular.js-6fb4bf4c543b3e48375221a9c5f1791af31a3ffc.tar.bz2
fix(directives): make ng:class-even/odd work with ng:class
Closes #508
Diffstat (limited to 'test/directivesSpec.js')
-rw-r--r--test/directivesSpec.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/directivesSpec.js b/test/directivesSpec.js
index 22d3c84b..afb4e04f 100644
--- a/test/directivesSpec.js
+++ b/test/directivesSpec.js
@@ -220,6 +220,50 @@ describe("directive", function(){
expect(e2.hasClass('even')).toBeTruthy();
});
+
+ it('should allow both ng:class and ng:class-odd/even on the same element', function() {
+ var scope = compile('<ul>' +
+ '<li ng:repeat="i in [0,1]" ng:class="\'plainClass\'" ' +
+ 'ng:class-odd="\'odd\'" ng:class-even="\'even\'"></li>' +
+ '<ul>');
+ scope.$eval();
+ var e1 = jqLite(element[0].childNodes[1]);
+ var e2 = jqLite(element[0].childNodes[2]);
+
+ expect(e1.hasClass('plainClass')).toBeTruthy();
+ expect(e1.hasClass('odd')).toBeTruthy();
+ expect(e1.hasClass('even')).toBeFalsy();
+ expect(e2.hasClass('plainClass')).toBeTruthy();
+ expect(e2.hasClass('even')).toBeTruthy();
+ expect(e2.hasClass('odd')).toBeFalsy();
+ });
+
+
+ it('should allow both ng:class and ng:class-odd/even with multiple classes', function() {
+ var scope = compile('<ul>' +
+ '<li ng:repeat="i in [0,1]" ng:class="[\'A\', \'B\']" ' +
+ 'ng:class-odd="[\'C\', \'D\']" ng:class-even="[\'E\', \'F\']"></li>' +
+ '<ul>');
+ scope.$eval();
+ var e1 = jqLite(element[0].childNodes[1]);
+ var e2 = jqLite(element[0].childNodes[2]);
+
+ expect(e1.hasClass('A')).toBeTruthy();
+ expect(e1.hasClass('B')).toBeTruthy();
+ expect(e1.hasClass('C')).toBeTruthy();
+ expect(e1.hasClass('D')).toBeTruthy();
+ expect(e1.hasClass('E')).toBeFalsy();
+ expect(e1.hasClass('F')).toBeFalsy();
+
+ expect(e2.hasClass('A')).toBeTruthy();
+ expect(e2.hasClass('B')).toBeTruthy();
+ expect(e2.hasClass('E')).toBeTruthy();
+ expect(e2.hasClass('F')).toBeTruthy();
+ expect(e2.hasClass('C')).toBeFalsy();
+ expect(e2.hasClass('D')).toBeFalsy();
+ });
+
+
describe('ng:style', function(){
it('should set', function(){
var scope = compile('<div ng:style="{height: \'40px\'}"></div>');