Advertisement
Varun_Krishna

Spying on a javascript function

Feb 1st, 2014
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //how to spy on a normal java script function ???
  2. //note when I try to access it with $scope.arithmetic I am getting errors
  3. function arithmetic() {
  4. addFn(value1, value2);
  5. subFn(value1, value2);
  6. multFn(value 1, value 2);
  7. DivFn(value 1, value 2);
  8. }
  9.  
  10. //spec.js
  11. .....
  12. .....
  13. spyOn(scope, 'arithmetic');
  14. scope.arithmetic();
  15. expect(scope.arithmetic).toHaveBeenCalled();
  16. //but I also want to check whether these functions add, mult .... have been called. so how do I do this?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement