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
angularjs jasmine


source to share


No one has answered this question yet

Check out similar questions:

1006
What is the difference between angular-route and angular-ui-router?
476
AngularJS ngClass conditional
115
Unit Testing AngularJS Directive with TemplateUrl
103
How do I test an AngularJS service with Jasmine?
40
using Jasmines spyon by private method
8
jasmine spyOn angular inner methods like $ filter ('date')
4
Angular Jasmine request call spyOn
3
How do I use the spyOn Angular factory method?
2
How to access a private function at the factory
0
Unit testing corner function using Karma Jasmine



All Articles
Loading...
X
Show
Funny
Dev
Pics