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.
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 );
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With