javascript - Jasmine trigger Button Event -
i have following click handler wrapped in class
var testui = function (chatclient, document, elements) { testui.prototype = { applylistenerstoelements: function () { var self = this; this.elements.mybutton.click(function () { self.myclient.postdata(data).then(function (response) { //all's if(response) { ....do } }, function (err) { console.log("error " + err); }); }); } }
how write jasmine test simulate/perform actual click event if clicked on in browser ? how mock objects , events ? have provide html snippet in mock or can use html that's in actual file, perhaps using jasmine.getfixtures()
just come across while ago seems answer question.
https://luizfar.wordpress.com/2011/01/10/testing-events-on-jquery-objects-with-jasmine/
and can read in html external file using jasmine.getfixtures().fixturespath = 'my/new/path';
from https://github.com/velesin/jasmine-jquery.
this ok
http://codepen.io/jweden/pen/irmil
hope helps else
Comments
Post a Comment