vendredi 16 décembre 2016

How to test for the presence of a Link component with a specific href

I'm trying out some tests with expect and enzyme, and I'm trying to add some tests for a <Header /> Component.

For the Header, I want to test that somewhere it contains a link to /login. Inside my header it's implemented like this:

<Link className="nav-link" to="/login">Login</Link>

Ideally, I would also set the state of the user to be logged in or not logged in and then test whether or not the Link renders a link to /login or a link to /logout.

I've been reading through the docs for enzyme and searching online but haven't found any tips on this. Any ideas?

Aucun commentaire:

Enregistrer un commentaire