mercredi 1 mars 2017

How do I test this function using Jasmine?

I'm pretty new to Jasmine testing, and I'm facing a small problem. I have a function like this:

function clickThis(){
    document.getElementById("link").click();
}

How do I test that this function has been called / triggered in my test?

This is my test currently:

it(" checks if the clickThis() method is triggered", function(){
    var spyEvent = spyOnEvent("#link", 'click');
    ("#link").click();
    expect(spyEvent).toHaveBeenTriggered();
});

But doing this, gives me this error:

TypeError: "#link".click is not a function

How do I fix this test? Any help is greatly appreciated!

Aucun commentaire:

Enregistrer un commentaire