dimanche 5 juin 2016

jasmine test - mock element html

I want to write test to my JS script. I have on my HTML page input element, which receives values through user. My JS script gets this values and creates JSON object.

HTML

<input name="test1" type="text" id="inputWord1">
<input name="test2" type="text" id="inputWord2">

JS script

var myFun = function(){
    var data = {};
    data.first = $('#inputWord1').val();
    data.second = $('#inputWord2').val();
    return data;
}

In my script Jasmine I would like to simulate data input.

I suppose, that I should mock html element in Jasmine. The html element will be fake input data.

But, I don't know how implement this in Jasmine.

Aucun commentaire:

Enregistrer un commentaire