How do you unit test a filter in Angular?
Filter can be injected right into test (have found a snippet here)
describe('myApp', function () {
beforeEach(function () {
module('myApp');
});
it('has a bool filter', inject(function($filter) {
expect($filter('bool')).not.toBeNull();
}));
it("should return true empty array ", inject(function (boolFilter) {
expect(boolFilter(true)).toBeTruthy();
}));
});
In this example filter name is 'bool', in order to inject this filter you shall use 'bool' + 'Filter' = 'boolFilter'