I am writing the test cases of my application using karma and jasmine. I am new in unit testing. Here is my code:
$scope.$watch('filterParams.statusModel', function() {
$scope.customFilters.statusArray = customFilters.statusArray.filter(function(_i) {
var _x = $scope.filterParams.statusModel.toLowerCase();
if (_i.value.toLowerCase().indexOf(_x) !== -1) {
return true;
}
return false
})
});
Test case is:
it('\n Watch function fire continously', function () {
scope.customFilters = {
statusArray: [{value:'Active'},{value:'InActive'}],
status:[{'active':true},{'InActive':true}]
}
scope.filterParams = {};
scope.filterParams.statusModel = 'Active'
scope.$apply()
scope.filterParams.statusModel = 'InActive'
scope.$apply()
});
It does not show any error and test case run succesfully,but in code coverage it show me red, that means your code is not covered