So, I'm trying to test using MemoryRouter that if i click a button that is supposed to take me to a new Route, it does actually open that route.
so 'ConversationView' is the react component inside Conversations. i want to be able to test that when i click on the button that's located inside 'Conversations', i would be able to reach the new route 'ConversationsView' and find the 'h2' tag inside it.
this is my code:
const wrapper = mount(
<MemoryRouter initialEntries={[ "/" ]}>
<Conversations >
<ConversationView>
</ConversationView>
</Conversations>
</MemoryRouter>);
const button = wrapper.find("button").first();
button.simulate("click");
expect(wrapper.find("h2")).toHaveLength(1);
what am i doing wrong? how should i be testing such a scenario?
Aucun commentaire:
Enregistrer un commentaire