mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +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>');
|
||||
scope.$eval();
|
||||
expect(element.hasClass('existing')).toBeTruthy();
|
||||
expect(element.hasClass('A')).toBeTruthy();
|
||||
expect(element.hasClass('B')).toBeTruthy();
|
||||
|
||||
describe('ng:class', function() {
|
||||
it('should add new and remove old classes dynamically', function() {
|
||||
var scope = compile('<div class="existing" ng:class="dynClass"></div>');
|
||||
scope.dynClass = 'A';
|
||||
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(){
|
||||
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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue