unable to correctly write spyOn in Jasmine -
i unable correctly write spyon in jamine. in summary, learnjs has problemview has checkanswerclick
`use strict`; var learnjs = {}; //this top level object learnjs.problemview = function(data) { //i register button's callback here. code deleted brevity function checkanswer(){ ... } function checkanswerclick() { ... return false; } var b = view.find('.check-btn'); b.click(checkanswerclick); //callback registration } following jasmine spec. call click on button , want check tha callback called. error problemview.checkanswerclick() method not exist
it('can check correct answer hitting button', function(){ var b1 = view1.find('.check-btn'); b1.click(); spyon(learnjs,'problemview.checkanswerclick'); expect(view1.find('.result').text()).toequal('correct!'); expect(learnjs.problemview.checkanswerclick).tohavebeencalled();
Comments
Post a Comment