Trying to test with jasmine the constructor of a javascript library -
i had javascript code , wanted make reusable , testable i'm trying make library out of it. i've made in form of library i'm not able test constructor using jasmine.
my library code looks way:
window.menu = (function(){    function menu(){     this.additem('sample');   }    menu.prototype.additem(string){     console.log(string);   }    var menu = function(){     return new menu();   }  return menu; }()); now using jasmine, wan't write test testing not content of additem function, constructor, want know additem function called.
there similar question here, reason not working me. if write test:
describe("menu", function() {   it("test constructor", function() {     spyon(menu.prototype,'additem');     var newmenu = new menu();   } }); and get:
referenceerror: can't find variable: menu in file:///home/whatever/library-test/spec/menuspec.js i don't know why happening, test code wrong or i've chosen bad approach creating testable library code?