I don't know how to unit testing my filters. One of the examples are shown below:
angular.module('testApp')
.filter('range', ['$log', function ($log) {
return function (companylist, min, max) {
max = parseInt(max, 10) || 100;
var result = [];
angular.forEach(companylist, function (val) {
if (val.maxSpread >= min && val.maxSpread <= max) {
result.push(val);
}
});
return result;
}
}]);
How you can see the filter iterates an array companylist and if the max value will changed the result returns a new list of company.
The company object is structured as follows:
{
Id: 1,
name: 'CompanyName',
short: 'CN',
maxSpread: 25
}
I have no idea to test this filter. Looking for a unit test at several tutorials and blogs but I've not found anything what could help me.
Aucun commentaire:
Enregistrer un commentaire