1
00:00:01,140 --> 00:00:03,540
-: In the last section, we ended up at the very end

2
00:00:03,540 --> 00:00:06,390
trying to make our test fail by saying that we should find

3
00:00:06,390 --> 00:00:08,820
three LIs inside of our application.

4
00:00:08,820 --> 00:00:11,610
In reality, we only ever loaded up two comments

5
00:00:11,610 --> 00:00:14,940
from that fake endpoint that we created with Moxios.

6
00:00:14,940 --> 00:00:16,110
So if you flip back over

7
00:00:16,110 --> 00:00:18,420
you might see an error message that looks like this.

8
00:00:18,420 --> 00:00:19,680
We can very easily fix that

9
00:00:19,680 --> 00:00:21,780
by reverting it back over to the two.

10
00:00:21,780 --> 00:00:23,190
And that gives me a pretty good feeling

11
00:00:23,190 --> 00:00:25,110
to say that, yeah our test is failing

12
00:00:25,110 --> 00:00:27,570
the way we would expect it to fail.

13
00:00:27,570 --> 00:00:28,860
Okay, so in this section we're gonna do

14
00:00:28,860 --> 00:00:31,950
a quick little bit of cleanup inside this file.

15
00:00:31,950 --> 00:00:33,060
In the last section we spoke

16
00:00:33,060 --> 00:00:35,460
about why we had to introduce this timeout right here.

17
00:00:35,460 --> 00:00:36,720
We had said that Moxios needs

18
00:00:36,720 --> 00:00:40,230
just that tiny bit of time to kick in and do its thing.

19
00:00:40,230 --> 00:00:44,580
But using a set timeout right here is extremely imprecise.

20
00:00:44,580 --> 00:00:46,950
See, we put in a hundred milliseconds right here

21
00:00:46,950 --> 00:00:49,530
but it's entirely possible that Moxios kicks in

22
00:00:49,530 --> 00:00:51,840
much faster than a hundred milliseconds.

23
00:00:51,840 --> 00:00:52,980
And it's also conceivable

24
00:00:52,980 --> 00:00:56,010
that it could take it longer than a hundred milliseconds.

25
00:00:56,010 --> 00:00:58,500
So Moxios as a library understands

26
00:00:58,500 --> 00:01:00,960
that sometimes it's gonna take a little bit of time

27
00:01:00,960 --> 00:01:04,230
for it to actually kick in and respond to these requests

28
00:01:04,230 --> 00:01:08,250
with the provided response that we created right here.

29
00:01:08,250 --> 00:01:11,970
So to help you and I out, Moxios exposes a function

30
00:01:11,970 --> 00:01:14,610
on the library that allows us to essentially

31
00:01:14,610 --> 00:01:16,800
do the same thing that the set timeout function

32
00:01:16,800 --> 00:01:18,180
right here is doing.

33
00:01:18,180 --> 00:01:20,040
So we're gonna replace our set timeout

34
00:01:20,040 --> 00:01:23,520
with a different function that's a part of Moxios.

35
00:01:23,520 --> 00:01:25,560
I'm gonna highlight the set timeout up here

36
00:01:25,560 --> 00:01:28,530
and I'll say Moxios dot wait.

37
00:01:28,530 --> 00:01:32,100
And then side of wait, I'm gonna pass an arrow function

38
00:01:32,100 --> 00:01:34,950
and then I'll close that thing off at the bottom like so.

39
00:01:35,850 --> 00:01:37,320
So I just kind of cannibalize

40
00:01:37,320 --> 00:01:39,750
the set timeout call we had.

41
00:01:39,750 --> 00:01:42,360
Do triple check to make sure you have Moxios dot wait,

42
00:01:42,360 --> 00:01:44,340
you pass in an arrow function,

43
00:01:44,340 --> 00:01:47,640
and then you close that arrow function off down here.

44
00:01:47,640 --> 00:01:49,410
So now we should be able to save this

45
00:01:49,410 --> 00:01:50,820
and then flip on over to the terminal

46
00:01:50,820 --> 00:01:54,780
and still see our test passing the way we would expect.

47
00:01:54,780 --> 00:01:57,270
So again, Moxios dot wait is gonna say,

48
00:01:57,270 --> 00:02:00,210
okay I understand there might be some pending request

49
00:02:00,210 --> 00:02:01,890
that needs to be resolved before you try

50
00:02:01,890 --> 00:02:05,070
to execute your request, risking your test logic.

51
00:02:05,070 --> 00:02:06,180
And that's what it's gonna do.

52
00:02:06,180 --> 00:02:07,013
It's gonna say, I'm just gonna

53
00:02:07,013 --> 00:02:08,850
hold onto this little arrow function

54
00:02:08,850 --> 00:02:11,160
and as soon as I see some incoming request,

55
00:02:11,160 --> 00:02:14,820
I'll then execute the callback that you just provided.

56
00:02:14,820 --> 00:02:17,040
And so that gives us a great place to put our ability

57
00:02:17,040 --> 00:02:18,780
in for updating our component,

58
00:02:18,780 --> 00:02:21,030
doing our expectation, and then calling done.

59
00:02:22,530 --> 00:02:23,790
So I'll flip back over

60
00:02:23,790 --> 00:02:26,460
and it looks like all my tests are still passing,

61
00:02:26,460 --> 00:02:29,160
particularly the integration test right here.

62
00:02:29,160 --> 00:02:29,993
Cool.

63
00:02:29,993 --> 00:02:31,320
So that looks pretty good.

64
00:02:31,320 --> 00:02:34,440
And I think that our test suite is just about complete.

65
00:02:34,440 --> 00:02:37,020
I think that's just about everything we can do.

66
00:02:37,020 --> 00:02:38,670
So let's take a quick pause right now.

67
00:02:38,670 --> 00:02:39,720
We'll come back the next section

68
00:02:39,720 --> 00:02:42,693
and we'll do a little bit of wrap up on our testing app.

