mardi 4 avril 2017

Testing React with Enzyme

As a newcomer in the world of enzyme: How can I test following construction?

return (this.FAQData.context[context])
        ? this.FAQData.context[context]
        : this.FAQData.context.default;

code coverage (istanbul) report:

enter image description here

Following tests did not help, although they work successfully:

it ("checks if FAQData has questions for a certain route", () => {
    let someRoute = '/dashboard';
    expect(wrapper.instance().FAQData.context[someRoute].length).not.to.be.null;
});

it ("checks if FAQData.context[someRoute] is true", () => {
    let someRoute = '/dashboard';
    let result = wrapper.instance().FAQData.context[someRoute] ? true : false;
    expect(result).to.be.true;
});

P.s. (Mocha + Chai + Enzyme + Istanbul)

Aucun commentaire:

Enregistrer un commentaire