Jasmine SpyOn Window Function in AngularJS Application -


i've created function upon route change:

window.intercom = function(action, msg) {   return window.intercom(action, msg); }; 

am trying spy on function don't understand how. followed advice in this post.

if use this:

beforeeach(inject(function($compile, $rootscope, $q, _$location_, $routeparams) {   element = angular.element("<add-box></add-box>");   $compile(element)($rootscope); }));  it("should cancel adding box!", function() {   spyon(window, 'intercom') }); 

i error:

intercom() method not exist 

so tried this:

it("should cancel adding box!", function() {   var intercom = jasmine.createspy(); }); 

which says:

typeerror: 'undefined' not function (evaluating 'window.intercom('hide')') 

how can work? i'm sure it's simple, i'm new jasmine.

how in beforeeach or better in before function this:

window.intercom = jasmine.createspy(); 

that'll intercom function on window.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -