jeudi 9 avril 2015

AngularJS - Mock $window in unit test

I am trying to mock $window object with this:



var mock$window = {
scrollTop : 150,
height : 600
};
$provide.value('$window', mock$window);


When I run the test, I am able to get $window.scrollTop() value, but when I try with $window.height(), I get the error of Cannot use 'in' operator to search for 'height' in undefined.


What is the proper way to mock $windows object?


Aucun commentaire:

Enregistrer un commentaire