Instructor: In this section,
we're gonna work on our last test
around the comment box.
So, in this last test, we want to enter some text
into the text area, submit the form,
and then make sure that the text area
gets emptied out completely.
So, for this test, we're gonna end up with some code,
that looks pretty darn similar,
to the test we just put together right here.
It's gonna have one or two extra steps inside of it
to verify that we actually submit that form.
But in general, it's gonna look pretty darn similar.
So, with that in mind, I would like you to give a shot
at putting this test together.
So, I would like you to try to write a test,
that enters some text into the text area,
submits the form,
and then verifies that the text area is completely empty,
or has an empty string as its value.
Now, I'm gonna give you one quick tip here,
when you're putting this together, you might be thinking,
that to submit the form, we want to trigger
some kind of click event on this button right here.
Unfortunately, that's not quite what we want to do.
You see, when we simulate events, that causes enzyme
to look at every JSX tag,
that we had added to our component,
and try to find if that component had an event,
callback, related to the event that we're simulating.
So, in this case, our button element right here,
does not actually have an onClick or onSubmit,
or any type of event handler like that.
It is solely, the browser itself,
and the way the browser works of handling button clicks
inside a form elements that makes a click on the button,
button right here, submit the form.
So, in other words,
in order to trick our component into thinking,
that our form element or our form tag has been submitted.
We need to simulate a submit event on the form itself.
Okay, so that's kind of the trick behind this,
is to make sure that you attempt to submit the submit event,
or excuse me, simulate the submit event on the form
rather than trying to simulate a click on the button.
So, I'd like you to give a shot at this test.
Give it the best shot you can,
if you get stuck.
Hey, don't sweat it.
Just continue on to the next section,
and we'll go over the solution together.
So, quick break and I'll see you in just a minute.