File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Testing javascript function that is not within an object

 
Amit Bhargava
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a function as follows:



callMethod is another function in the same js file being tested. Both functions are not within any object.

I want to set a spy on callMethod, but am unable to do so. I keep getting errors in Jasmine stating 'callMethod() method does not exist'

What should be the object that is set as the first parameter of spyOn()?
 
Amit Bhargava
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just noticed I've accidentally posted this in the wrong forum. How do I move it to 'JSP'?
 
Paul Clapham
Sheriff
Pie
Posts: 20196
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP? But it's a question about Javascript. Can't possibly have anything to do with JSP. But we can move it to the HTML/Javascript forum... it is about Javascript, after all.
 
Amit Bhargava
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul!
 
Amit Bhargava
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally got around it by creating a fake object. The fake object calls the desired function and is spied on.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic