File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Testing javascript function that is not within an object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Testing javascript function that is not within an object" Watch "Testing javascript function that is not within an object" New topic
Author

Testing javascript function that is not within an object

Amit Bhargava
Greenhorn

Joined: May 20, 2011
Posts: 20
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

Joined: May 20, 2011
Posts: 20
Just noticed I've accidentally posted this in the wrong forum. How do I move it to 'JSP'?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18563
    
    8

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

Joined: May 20, 2011
Posts: 20
Thanks Paul!
Amit Bhargava
Greenhorn

Joined: May 20, 2011
Posts: 20
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
 
subject: Testing javascript function that is not within an object