This is a simple test of simulating comment existing in textarea, while first test is passing, next one simulating submiting text from textarea, running handleSubmit (connected to my form for now) which clear the textarea, but test pointing that comment is expected (poiting to => .toEqual("");
beforeEach(() => {
wrapper.find("textarea").simulate("change", {
target: { value: "new comment" }
});
wrapper.update();
});
it("has a text area that user can type into", () => {
expect(wrapper.find("textarea").prop("value")).toEqual("new comment");
});
it("simulate button click (in real form submit) and clear textarea", () => {
wrapper.update();
wrapper.find("form").simulate("submit");
wrapper.update();
expect(wrapper.find("textarea").prop("value")).toEqual("");
});
});
Aucun commentaire:
Enregistrer un commentaire