1
我需要在作为过滤器的控制器中编写一个作用域函数。单元测试作为过滤器的作用域函数
$scope.filterR = function(s) {
return function(c) {
for (var prop in c) {
if (c[prop].toSomething() >= 0) {
return c;
break;
}
}
}
}
这就是我使用它的方式。
<div ng-repeat="c in cus | filter: filterR(s)">
</div>
我面临的麻烦是如何在业力茉莉花测试这个特定的例程。
我目前的测试看起来像这样,
describe('check x', function() {
it('check abc', function() {
var $scope = {};
var controller = $controller('SController', {
$scope: $scope
});
expect($scope.filterResults('some_data')).toEqual(
some_data
);
});
过滤器工作正常,但它给了我一个问题,编写测试。任何帮助表示赞赏。