Reputation: 151
I have a Controller that has this line of code
var formattedDate= $filter('date')(dateColName,short);
I am trying unit test this controller and I am not clear on how to mock the date filter in my code.
Upvotes: 11
Views: 8910
Reputation: 549
You need to add 'Filter' to the end of your filter name when mocking a filter in Angular, as Angular stores filter like services, but adds 'Filter' to the end. Try this for example:
var mockFilter = function() {
return 'whatyouwantittoreturn';
};
beforeEach(function() {
module(function($provide) {
$provide.value('dateFilter', mockFilter );
});
});
Upvotes: 21