I know my question may be simple, but I am a debutante in web. I coded a form with js and html. I wrote a function in order to alert when the symbol in input is not a number and I m trying to write test for this function, with jest. But my function has no input and no return because it gets back information from my html page. I don't know how simulate an input in html in my js file of test, my function can get to check if it is ok. Tank you to take 5 minutes to answer me. Elisa
function checkNum() {
var valeur = document.formulaire.inputDateDeQuoi.value;
var reg = new RegExp("[^0-9/]", "i");
var qui = document.querySelector('#dateDeQuoi .err');
if (valeur.match(reg)) {
qui.innerHTML = "<span style='color:
rgb(200,10,70);'>Attention ! Ce champ ne doit contenir que des
chiffres !</span>";
autoComp.value = -1;
}
else {
qui.innerHTML = "";
}
document.getElementsByName('inputDateDeQuoi')
[0].addEventListener('keyup', checkNum);
module.export = checkNum;
Aucun commentaire:
Enregistrer un commentaire