-: In the last section, we ended up at the very end
trying to make our test fail by saying that we should find
three LIs inside of our application.
In reality, we only ever loaded up two comments
from that fake endpoint that we created with Moxios.
So if you flip back over
you might see an error message that looks like this.
We can very easily fix that
by reverting it back over to the two.
And that gives me a pretty good feeling
to say that, yeah our test is failing
the way we would expect it to fail.
Okay, so in this section we're gonna do
a quick little bit of cleanup inside this file.
In the last section we spoke
about why we had to introduce this timeout right here.
We had said that Moxios needs
just that tiny bit of time to kick in and do its thing.
But using a set timeout right here is extremely imprecise.
See, we put in a hundred milliseconds right here
but it's entirely possible that Moxios kicks in
much faster than a hundred milliseconds.
And it's also conceivable
that it could take it longer than a hundred milliseconds.
So Moxios as a library understands
that sometimes it's gonna take a little bit of time
for it to actually kick in and respond to these requests
with the provided response that we created right here.
So to help you and I out, Moxios exposes a function
on the library that allows us to essentially
do the same thing that the set timeout function
right here is doing.
So we're gonna replace our set timeout
with a different function that's a part of Moxios.
I'm gonna highlight the set timeout up here
and I'll say Moxios dot wait.
And then side of wait, I'm gonna pass an arrow function
and then I'll close that thing off at the bottom like so.
So I just kind of cannibalize
the set timeout call we had.
Do triple check to make sure you have Moxios dot wait,
you pass in an arrow function,
and then you close that arrow function off down here.
So now we should be able to save this
and then flip on over to the terminal
and still see our test passing the way we would expect.
So again, Moxios dot wait is gonna say,
okay I understand there might be some pending request
that needs to be resolved before you try
to execute your request, risking your test logic.
And that's what it's gonna do.
It's gonna say, I'm just gonna
hold onto this little arrow function
and as soon as I see some incoming request,
I'll then execute the callback that you just provided.
And so that gives us a great place to put our ability
in for updating our component,
doing our expectation, and then calling done.
So I'll flip back over
and it looks like all my tests are still passing,
particularly the integration test right here.
Cool.
So that looks pretty good.
And I think that our test suite is just about complete.
I think that's just about everything we can do.
So let's take a quick pause right now.
We'll come back the next section
and we'll do a little bit of wrap up on our testing app.