aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/CompilerSpec.js2
-rw-r--r--test/directivesSpec.js45
2 files changed, 45 insertions, 2 deletions
diff --git a/test/CompilerSpec.js b/test/CompilerSpec.js
index 3ea2e473..57b597c4 100644
--- a/test/CompilerSpec.js
+++ b/test/CompilerSpec.js
@@ -40,7 +40,7 @@ describe('compiler', function(){
directives.directive = function(expression, element){
log += "found";
expect(expression).toEqual("expr");
- expect(element.element).toEqual(e);
+ expect(element[0]).toEqual(e);
return function initFn() {
log += ":init";
};
diff --git a/test/directivesSpec.js b/test/directivesSpec.js
index 7e0446ef..d125d326 100644
--- a/test/directivesSpec.js
+++ b/test/directivesSpec.js
@@ -6,7 +6,7 @@ describe("directives", function(){
var compiler = new Compiler(angularMarkup, angularDirective, angularWidget);
compile = function(html) {
element = jqLite(html);
- var view = compiler.compile(element.element)(element.element);
+ var view = compiler.compile(element)(element);
view.init();
return view.scope;
};
@@ -108,4 +108,47 @@ describe("directives", function(){
element.click();
expect(scope.get('clicked')).toEqual(true);
});
+
+ it('should ng-class', function(){
+ var scope = compile('<div class="existing" ng-class="[\'A\', \'B\']"></div>');
+ scope.updateView();
+ 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.updateView();
+ var e1 = jQuery(element.parent()[0]).find('li:first');
+ var e2 = jQuery(element.parent()[0]).find('li:last');
+ expect(e1.hasClass('existing')).toBeTruthy();
+ expect(e1.hasClass('even')).toBeTruthy();
+ expect(e2.hasClass('existing')).toBeTruthy();
+ expect(e2.hasClass('odd')).toBeTruthy();
+ });
+
+ it('should ng-style', function(){
+ var scope = compile('<div ng-style="{color:\'red\'}"></div>');
+ scope.updateView();
+ expect(element.css('color')).toEqual('red');
+ });
+
+ it('should ng-show', function(){
+ var scope = compile('<div ng-hide="hide"></div>');
+ scope.updateView();
+ expect(element.css('display')).toEqual('');
+ scope.set('hide', true);
+ scope.updateView();
+ expect(element.css('display')).toEqual('none');
+ });
+
+ it('should ng-hide', function(){
+ var scope = compile('<div ng-show="show"></div>');
+ scope.updateView();
+ expect(element.css('display')).toEqual('none');
+ scope.set('show', true);
+ scope.updateView();
+ expect(element.css('display')).toEqual('');
+ });
});