mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-08 23:04:45 +00:00
test:ng#class: added a better unit test for ng:class
This commit is contained in:
parent
6aee2938a7
commit
75bc59ee4b
1 changed files with 30 additions and 6 deletions
|
|
@ -175,14 +175,38 @@ describe("directive", function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should ng:class', function(){
|
|
||||||
var scope = compile('<div class="existing" ng:class="[\'A\', \'B\']"></div>');
|
describe('ng:class', function() {
|
||||||
scope.$eval();
|
it('should add new and remove old classes dynamically', function() {
|
||||||
expect(element.hasClass('existing')).toBeTruthy();
|
var scope = compile('<div class="existing" ng:class="dynClass"></div>');
|
||||||
expect(element.hasClass('A')).toBeTruthy();
|
scope.dynClass = 'A';
|
||||||
expect(element.hasClass('B')).toBeTruthy();
|
scope.$eval();
|
||||||
|
expect(element.hasClass('existing')).toBe(true);
|
||||||
|
expect(element.hasClass('A')).toBe(true);
|
||||||
|
|
||||||
|
scope.dynClass = 'B';
|
||||||
|
scope.$eval();
|
||||||
|
expect(element.hasClass('existing')).toBe(true);
|
||||||
|
expect(element.hasClass('A')).toBe(false);
|
||||||
|
expect(element.hasClass('B')).toBe(true);
|
||||||
|
|
||||||
|
delete scope.dynClass;
|
||||||
|
scope.$eval();
|
||||||
|
expect(element.hasClass('existing')).toBe(true);
|
||||||
|
expect(element.hasClass('A')).toBe(false);
|
||||||
|
expect(element.hasClass('B')).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should support adding multiple classes', function(){
|
||||||
|
var scope = compile('<div class="existing" ng:class="[\'A\', \'B\']"></div>');
|
||||||
|
scope.$eval();
|
||||||
|
expect(element.hasClass('existing')).toBeTruthy();
|
||||||
|
expect(element.hasClass('A')).toBeTruthy();
|
||||||
|
expect(element.hasClass('B')).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should ng:class odd/even', function(){
|
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>');
|
var scope = compile('<ul><li ng:repeat="i in [0,1]" class="existing" ng:class-odd="\'odd\'" ng:class-even="\'even\'"></li><ul>');
|
||||||
scope.$eval();
|
scope.$eval();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue