[英]Unit test case for angular directive to manipulate css
angular.module('myApp').directive(errorDirective, function(){
return {
link: function(scope, element, attributes){
element.bind('change paste keyup', function(){
var value= $(this).val();
if(value < 100)
$('#inputerror').removeClass('dispnone').addClass('dispblock');
else if(value >100 && value <500)
$('#inputerror').removeClass('disp').addClass('dblock');
else
$('#inputerror').removeClass('dnone').addClass('displayblock');
});
}
}
});
在我的html文件中
<input id= 'inputvalue' ng-model="inputvalue" errorDirective/>
<span id= 'inputerror' class="errorNone"><span>Error occurs </span></span>
如何为给定指令编写单元测试用例?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.