SpyOn a Angular Custom Filter

I would like to know how I can SpyOn customize the filter. For example my code is

$scope.getLink = function() {
                    return $filter('BaseUrl')('/test.html');
                };

      

I want spyOn $ filter ('BaseUrl') in my Jasmine test so that it returns a string. something like that

spyOn($filter,'BaseUrl').andReturn('http://localhost');
expect(scope.getLink()).toEqual('http://localhost/test.html');

      

How can i do this.

Thanks in advance,

+3


source to share





All Articles