I am writing a Jasmine test to determine that a function is called by the JQuery click () method. Where is my logic wrong? Am I looking at a jquery function or a custom function?
I get an error message:
-error
Expected a spy, but got undefined. in http://localhost:8080/...etc.../jasmine.js (line 1253)
code
describe("funtionCalled", function() { it("calls the click() function", function() { var cc = new CustomClass(); spyOn($.fn, "click"); $( '#fieldID' ).click(); expect(cc.clickFunction()).toHaveBeenCalled(); }); });
- test code
var CustomClass = function(){}; $(document).ready(function(){ var cf = new CustomClass(); $( '#fieldID' ).click(function() { cf.clickFunction(); }); }); CustomClass.prototype.clickFunction = function() {
coder source share